#include <iostream>
using namespace std;
const int BASE10 = 10;
const int DIGIT = 1;
int countDigit(int n, int digit)
{
int count;
count = 0;
while(n) {
if(n % BASE10 == digit)
count++;
n /= BASE10;
}
return count;
}
int main()
{
int n, count;
cin >> n;
count = 0;
for(int i=1; i<=n; i++)
count += countDigit(i, DIGIT);
cout << count << endl;
return 0;
}