#include #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef pairP; int main() { ll a = 1e9 + 1; ll n; cin >> n; int cnt = 0; for (int i = 1; i < 9; i++) { for (int j = 1; j <= 9; j++) { string s; rep(k, i)s += j + '0'; ll b = stoll(s); if (a*b > n)break; else cnt++; } } cout << cnt << endl; }