#include <iostream>
#include <type_traits>
using namespace std;
bool Gen(int x) {
int g = 0;
while (x != 0) {
if (x % 10 == 7) {
return false;
break;
}
x /= 10;
}
return true;
}
int main() {
int n;
std::cin >> n;
int y=0;
for (int i = 0; i <= n; ++i) {
if (i % 7 != 0 && Gen(i) == true) {
y += i * i;
}
}
std::cout << y << std::endl;
}

京公网安备 11010502036488号