#include <bits/stdc++.h>
using namespace std;
int cnt;
bool is_seven (int i) {
if (i % 7 == 0 || i % 10 == 7 || i / 10 == 7) {
return true; // 与 7 有关
} else {
return false;
}
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
if (!is_seven(i)) {
cnt += i * i;
}
}
cout << cnt;
return 0;
}