#include<bits/stdc++.h>
using namespace std;
int tag[101]={0};
bool test(int n)
{
if( 0==(n%7) )
{
return true;
}
char demo[4];
sprintf(demo, "%d",n);
for( auto c : demo )
{
if( c=='7' )
{
return true;
}
}
return false;
}
void init()
{
for(int i=1; i<101; ++i)
{
if( test(i) )
{
tag[i]=1;
}
}
}
int main()
{
init();
long long n;
while( ~scanf("%lld",&n) )
{
long long sum=0;
for(long long i=1; i<=n; ++i)
{
if( !tag[i] )
{
sum+=( i*i );
}
}
printf("%lld\n",sum);
}
return 0;
} 
京公网安备 11010502036488号