#include using namespace std; #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) #define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--) #define all(a) (a).begin(),(a).end() const bool DEBUG = true; #define dump(a) if (DEBUG) cout << (a) << endl; typedef long long ll; typedef pair P; ll N; void solve() { ll p = (ll)1e9 + 1; ll count = 0; cin >> N; rep2(n, 1, 10) { if (N >= n * p) { dump(n); count++; } } rep2(i, 1, (int)1e4) { string s1, s2; s1 = s2 = to_string(i); reverse(all(s2)); ll n = stoll(s1 + s2); if (N >= n * p) { dump(n); count++; } rep(i, 10) { ll n = stoll(s1 + to_string(i) + s2); if (N >= n * p) { dump(n); count++; } } } cout << count << endl; } int main() { solve(); return 0; }