#include <stdio.h>

int main()
{
    int L = 0;
    int R = 0;
    scanf("%d %d", &L, &R);//输入
    int i = 0;
    int count = 0;//数字2出现的次数
    for (; L <= R; L++)//遍历范围[L, R]内的所有整数
    {
        i = L;//存值
	  
	  //计算
        while (i)
        {
            if (2 == i % 10)
            {
                count++;
            }
            i /= 10;
        }
    }
    printf("%d\n", count);//输出
    return 0;
}