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