#include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; constexpr ll mod = (ll)1e9 + 1LL; const ll num = n / mod; constexpr ll max = 9999; ll cnt = min(num, 9LL); for (ll i = 1; i <= max; i++) { string s = to_string(i); string rev = s; reverse(rev.begin(), rev.end()); for (ll d = -1; d < 10; d++) { const string sep = (d == -1) ? "" : to_string(d); const ll v = stoll(s + sep + rev); if (0 < v and v <= num) { cnt++; } } } cout << cnt << endl; return 0; }