#include<bits/stdc++.h>
using namespace std;
bool hw(int n){
	bool r=false;
	int x=n,s=0;
	while (x!=0){
		s=s*10+x%10;
		x=x/10;
	}
	if(s==n)r=true;
	else r=false;
	return r;
}
int main(){
	int n,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(hw(i)) c++;
	}
	cout<<c;
	return 0;
}

/**************************************************************
	Problem: 1149
	User: wuzihang
	Language: C++
	Result: Accepted
	Time:14 ms
	Memory:2072 kb
****************************************************************/