#include<bits/stdc++.h>
using namespace std;
long long sum = 0;
int main(){
for(int i = 1; i <= 2019; i++){
int s = i;
int judge = 0;
//对于while有几点要说:
//1.while()内的元素不能与外面for循环用的变量一致,例如这里
//若用i当i/=后为0时,导致for循环直接死循环无法退出
//2.s%10后得到的数,要另外开辟一个变量保存,否则会出现 s = 21
// s = s % 10导致s变为 1,而实际上s不应该变
while(s){
//judge判断是否有符合要求的数
judge = s % 10;
//if一定要放在%后,防止/产生的0对0的判断产生干扰
if(judge==0||judge==1||judge==2||judge==9){
sum += pow(i,2);
break;
}
judge /= 10;
s/=10;
}
}
cout<<sum<<endl;
return 0;
}