#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
    int cnt = 0, flag = 0; //计数
    string s;
    for (int i = 10000; i <= 99999; i++)
    {
        flag = 0;
        stringstream ss;
        ss << i;
        ss >> s;
        for (int j = 0; j < s.length(); j++)
        {
            if (s[j] == '4')
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
            cnt++;
    }
    cout << cnt;
    return 0;
}
