#include <bits/stdc++.h>
using namespace std;
int main()
{
int l, r, ans;
cin >> l >> r;
ans = 0;
for (int i = l; i <= r; i++)
{
int now = 0; //计算 i 里有几个 2
for (int j = i; j > 0; j /= 10)
if (j % 10 == 2)
now++;
ans += now;
}
cout << ans;
return 0;
}