#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
long long n;
int main() {
	cin >> n;
	int x = 1000000000;
	int p = n / x, q = n % x;
	int ret = 0;
	for (int i = 1; i <= 9; i++) {
		if (i < p || (i == p && i <= q)) ret++;
	}
	for (int i = 1; i < 10000; i++) {
		string t1 = to_string(i), t2 = t1;
		reverse(t2.begin(), t2.end());
		int z = stoi(t1 + t2);
		if (z < p || (z == p && z <= q)) ret++;
		for (int j = 0; j <= 9; j++) {
			int z2 = stoi(t1 + to_string(j) + t2);
			if (z2 < p || (z2 == p && z2 <= q)) ret++;
		}
	}
	cout << ret << endl;
	return 0;
}