//Java版代码
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 7 != 0 && i % 10 != 7) ans += i * i;
        }
        System.out.println(ans);
    }
}#Python版代码
print(sum(i * i for i in range(1, int(input()) + 1) if i % 10 != 7 and i % 7 != 0))