#include int main () { long long n = 0LL; int res = 0; long long ans = 0LL; long long prev_p = 9LL; long long cnt = 0LL; res = scanf("%lld", &n); for (int a = 0; a < 10; a++) { for (int b = 0; b < 10; b++) { if (a != b && prev_p < 1000000000LL) { long long nxt_p[2] = { prev_p, 1000000001LL }; while (nxt_p[1]-nxt_p[0] > 1LL) { long long nxt = (nxt_p[0]+nxt_p[1])/2LL; if (n*(nxt*((long long)a)+((long long)b)) > nxt*nxt-1LL) { nxt_p[0] = nxt; } else { nxt_p[1] = nxt; } } ans += (nxt_p[0]-prev_p)*cnt; prev_p = nxt_p[0]; cnt += 1LL; } } } ans = (prev_p-9LL)*90LL-ans; for (int i = 2; i < 10; i++) { for (int a = 0; a < i; a++) { for (int b = 0; b < i; b++) { if (a != b && n*((long long)(i*a+b)) > ((long long)(i*i-1))) { ans += 1LL; } } } } printf("%lld\n", ans); return 0; }