#include<iostream>
#include<algorithm>
using namespace std;
int cal (int x) {
int cnt = 0;
while (x) {
cnt += (x % 10 == 2);
x /= 10;
}
return cnt;
}
int main () {
int L,R;
cin >> L >> R;
int ans = 0;
for (int i = L;i <= R;i++) {
ans += cal(i);
}
cout << ans << endl;
}