#include <stdio.h>


int count2(int x)
{
    int sum = 0;
    while (x)
    {
        if (x%10 == 2)
        {
            sum++;
        }
        x /= 10;
    }
    return sum;
}


int main() {
    int a, b;
    while (scanf("%d %d", &a, &b) != EOF) 
    {
        int count = 0;
        for (int i = a;  i <= b; i++)
        {
            count += count2(i);
        }

        printf("%d",count);
    }
    return 0;
}