#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

vector<int> num[5];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  for (int i = 1; i <= 1e5; i++) {
    string s = to_string(i);
    num[s.length()].push_back(i);
  }

  vector<int> cand { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  
  for (int d = 2; d <= 9; d++) {
    int h = d / 2;
    for (int x: num[h]) {
      string s = to_string(x);
      string t = s;
      reverse(t.begin(), t.end());

      if (d % 2) {
        for (char c = '0'; c <= '9'; c++) 
          cand.emplace_back(stoi(s + c + t));
      } else {
        cand.emplace_back(stoi(s + t));
      }
    }
  }

  long long n;
  cin >> n;

  long long ret = 0;
  for (long long x: cand) {
    if (x * 1000000001 <= n)
      ++ret;
  }
  cout << ret << endl;
  
  return 0;
}