#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

bool check(int x)
{
    while (x)
    {
        if (x % 10 == 2 || x % 10 == 4)
            return false;
        x /= 10;
    }
    return true;
}

int main()
{
    int ans = 0;
    for (int i = 1; i < 2019; i++)
    {
        if (!check(i))
            continue;
        for (int j = i + 1; j < 2019; j++)
        {
            int k = 2019 - i - j;
            if (k > j && check(j) && check(k)) ///此处记得j,k都要check
                ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}
