#include <stdio.h>

int main() {
    int a, b;
    int count=0;
    while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 

    for(int i=a;i<=b;i++){
        int val=i;
        while(val){
            if(val%10==2){
                count++;
            }
            val/=10;
        }
    }
    printf("%d",count);
    }
    return 0;
}