#include <bits\stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef unsigned long long ull ;
typedef long long ll ;
typedef pair<int, int>PII;
void solve(){
int n;
cin>>n;
if(n<10) {
cout<<n+1;
return ;
}
if(n==10){
cout<<10;
return ;
}
//计算位数算法需优化
int x = n;
int a = 1, b = 1;
int t = 1;
while(x/10){
a=x/10;
t++;
if(x/100==0&&x/10!=0){
b=x%10;
}
x/=10;
}
int ans;
if(a<=b) ans = a*t+*(t-1);
else ans = (a-1)*t+(11-a)*(t-1);
cout<<ans;
}
signed main(){
IOS;
int tt;
tt=1;
//cin>>tt;
while(tt--)
solve();
return 0;
}