#include <cmath>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
// 找规律 :
// 例如 25 * 25 - 25 = 600
// 600 % 10^2 == 0
// 2 表示 25 转成string的长度
// 满足 (i * i - i) % pow(10, to_sting(i).size()) 自守数个数 + 1
// 特例 0 和 1
// 0 * 0 - 0 = 0 自守数个数直接 + 1
// 1 * 1 - 1 = 0
int temp;
int count = 0;
for (int i = 0; i <= n; i ++) {
temp = i * i - i;
int len = to_string(i).size();
if (len == 1 && temp == 0) {
count ++;
} else {
if (temp % int(pow(10, len)) == 0) {
count ++;
}
}
}
cout << count << endl;
}
// 64 位输出请用 printf("%lld")