#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	long long n, ans = 0;
	cin >> n;
	n /= 1000000001;
	for(int i = 1; i < 1e5; i++){
		string v = to_string(i);
		string s = v, t = v;
		reverse(v.begin(), v.end());
		s += v;
		t += v.substr(1, v.size() - 1);
		if(stoll(s) <= n) ans++;
		if(stoll(t) <= n) ans++;
	}
	cout << ans << endl;
}