#include #include using namespace std; typedef long long ll; const ll x = 1e9 + 1; int main(){ ll n; cin >> n; int ans = 0; ll up = 1; while(up*up < n/x) up *= 10; ll tmp = 0; for(int i = 0; i < 9; i++){ tmp += x; if(tmp <= n) ans++; } for(ll i = 1; i <= up; i++){ string s = to_string(i); string t = s; reverse(t.begin(), t.end()); s += t; ll j = stoll(s); if(j <= n/x) ans++; } cout << ans << endl; return 0; }