#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i vec; for(ll i=1; i<=100000; ++i){ string s = to_string(i); string t = s + s + s; vec.push_back(stoll(t)); } ll N; cin >> N; auto itr = upper_bound(vec.begin(), vec.end(), N); cout << int(itr - vec.begin()) << endl; return 0; }