#include <iostream>
using namespace std;
bool func(int x){
if(x%7==0) return true;
else{
while(x){
int t=x%10;
if(t==7) return true;
x/=10;
}
}
return false;
}
int main() {
int n;
while(cin>>n){
int sum=0;
for(int i=1;i<=n;i++){
if(!func(i)) sum+=i*i;
}
cout<<sum<<endl;
}
return 0;
}

京公网安备 11010502036488号