#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int ans = 0;
for (int i = 1; i <= n; i++)
{
int m = i;
while (m)
{
if (m % 10 == 1)
ans++;
m /= 10;
}
}
cout << ans;
return 0;
}