#include<bits/stdc++.h>
using namespace std;
int n,f[10];
int pd(int x){if(x==0) return 1;int tot=0;while(x){x/=10;tot++;}return tot;}
int front(int x){int num;while(x){num=x%10;x/=10;}return num;}
int main(){
cin>>n;
f[0]=f[1]=1;
for(int i=2;i<=9;i++){f[i]=10*f[i-1]+int(pow(10,i-1));}
int sum=0,l=1;
while(true){
if(pd(n)==1){if(n>=1){cout<<sum+1<<endl;break;}else{cout<<sum<<endl;break;}}
if((pd(n)!=pd(l))){
sum=sum+f[pd(n)-1];
l=int(pow(10,pd(n)-1));
continue;
}else{
if(pd(n)==pd(l)&&front(l)==1&&front(n)==1){
sum=sum+n-l+1;
l=1;
n-=int(pow(10,pd(n)-1));
continue;
}else{
if(pd(n)==pd(l)&&front(l)==1&&front(n)!=1){
sum=sum+int(pow(10,pd(l)-1))+f[pd(l)-1];
l=l+int(pow(10,pd(l)-1));
continue;
}else{
if(pd(n)==pd(l)&&front(l)!=1&&(front(l)!=front(n))){
sum=sum+(front(n)-front(l))*f[pd(l)-1];
l=int(pow(10,pd(n)-1))*front(n);
continue;
}else{
if(pd(n)==pd(l)&&front(l)!=1&&(front(l)==front(n))){
l=1;
n=n-front(n)*int(pow(10,pd(n)-1));
continue;
}
}
}
}
}
}
return 0;
}