#include<stdio.h>
#include<string.h>
int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    int count = 0;
    for (int i = a; i <= b; i++) {
        int j = i;
        while (j) {
            if (j % 10 == 2)
                count++;
            j /= 10;
        }
    }
    printf("%d", count);
    return 0;
}