/*
*
题目描述:
一个正整数,如果它能被7整除,或者它的十进制表示法中某个位数上的数字为7,
则称其为与7相关的数.现求所有小于等于n(n<100)的与7无关的正整数的平方和。
输入:
案例可能有多组。对于每个测试案例输入为一行,正整数n,(n<100)
输出:
对于每个测试案例输出一行,输出小于等于n的与7无关的正整数的平方和。
样例输入:
21
样例输出:
2336
*/
import java.io.FileReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
class Main
{
public static final boolean DEBUG = false;
public static boolean is7(int n)
{
if (n % 7 == 0) return true;
while (n > 0) {
if (n % 10 == 7) return true;
n /= 10;
}
return false;
}
public static void main(String[] args) throws IOException
{
Scanner cin;
int n;
if (DEBUG) {
cin = new Scanner(new FileReader("d:\\OJ\\uva_in.txt"));
} else {
cin = new Scanner(new InputStreamReader(System.in));
}
while (cin.hasNext()) {
n = cin.nextInt();
int sum = 0;
for (int i = 0; i <= n; i++) {
if (is7(i)) continue;
sum += i * i;
}
System.out.println(sum);
}
}
}