#include #include using namespace std; using ll = long long; int main(void){ // Here your code ! ll n; cin >> n; //1 - 9 , 11 , 22 , 33 , 99 , 111 ll tmp = 1; ll res = 0; while(true){ for(int i = 1; i <= 9; i++){ if( (n) >= tmp * i * 1000000001 ){ //cout << tmp * i << endl; res++; }else{ cout << res << endl; return 0; } } tmp = tmp * 10 + 1; } }