#include #include #include using namespace std; int solve(int x) { int ret = 0; for (int i = 1; i <= 9; i++) { if (i <= x) ret++; } for (int i = 1; i < 10000; i++) { string t1 = to_string(i), t2 = t1; reverse(t1.begin(), t1.end()); if (stoi(t1 + t2) <= x) ret++; for (int j = 0; j <= 9; j++) { if (stoi(t1 + to_string(j) + t2) <= x) ret++; } } return ret; } long long n; int main() { cin >> n; int x = 1000000000; int p = n / x, q = n % x; cout << solve(p - 1) + (q >= p) << endl; return 0; }