#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;
}
/**************************************************************
	Problem: 1149
	User: yangjunwen
	Language: C++
	Result: Accepted
	Time:17 ms
	Memory:2072 kb
****************************************************************/