#include <stdio.h>

//函数名的意思是2出现的次数
int Number2OfOccurrences(int L, int R)
{
    int count = 0;  //记录二出现的次数
    for(int i = L; i <=R; i++)
    {
        int tmp = i;
        while (tmp) 
        {
            //判断余数为2,计数加一
            if(tmp % 10 == 2)
                count++;
            
            tmp /= 10;
        }
    }

    return count;
}

int main() {
    int L, R;
    scanf("%d %d", &L, &R);

    int sum = Number2OfOccurrences(L, R);
    printf("%d", sum);
}