#include<iostream>
using namespace std;
int solveMethod(int n)
{
int ans = n;
int temp = 0;
int k = 0;
int j = 1;
while(n > 0)
{
if(n % 10 > 4)
{
temp += (n % 10 - 1)*k + j;
}
else
{
temp += (n % 10)*k;
}
k = k*9 + j;
j = j*10;
n = n / 10;
}
return ans - temp;
}
int main()
{
int n;
cin >> n;
cout << solveMethod(n) << endl;
return 0;
}