#include <bits/stdc++.h>
using namespace std;
bool f(int n)
{
    while (n)
    {
        int t = n % 10;
        if (t == 0 || t == 2 || t == 1 || t == 9)
            return true;
        n /= 10;
    }
    return false;
}
int main()
{
    long long sum = 0;
    for (int i = 1; i <= 2019; ++i)
        if (f(i))
            sum += i * i;
    cout << sum << endl;
    return 0;
}
