#include #include using namespace std; using namespace atcoder; using ll = long long; ll N, ans; string S; int main() { cin >> N; for (int i = 1; i <= 99999; i++) { S = to_string(i); S = S + S + S; if (stoll(S) <= N) ans++; else break; } cout << ans << endl; return 0; }