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