#include <iostream>
using namespace std;
typedef long long ll;
int cal(int t){
int cnt = 0;
while(t){
if(t % 10 == 2) cnt ++ ;
t /= 10;
}
return cnt;
}
int main(){
int l, r; cin >> l >> r;
ll res = 0;
for(int i = l; i <= r; i ++ ) res += cal(i);
cout << res << endl;
return 0;
}