#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using ll = long long;

int ten(int x)
{
	if (x == 0)return 1;
	return ten(x - 1) * 10;
}

int main(void)
{
	ll n;
	cin >> n;
	int ans = 0;
	for (int d = 1; d <= 9; ++d)
	{
		int half = d / 2 + (d % 2);
		int dow = ten(half - 1);
		int lim = ten(half);
		for (int i = dow; i < lim; ++i)
		{
			//if (i % 10 == 0)continue;
			char form[20];
			sprintf(form, "%%0%dd", half);
			char str[20];
			char rev[20];
			sprintf(str, form, i);
			strcpy(rev, str);
			reverse(rev, rev + half);
			if (d % 2)str[d / 2] = '\0';
			strcat(str, rev);
			ll out = atoll(str);
			out *= 1000000001;
			if (out <= n)
			{
				cerr << out << endl;
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}