#include #define rep(i,n) for(int i = 0; i < n; i++) #define srep(i,a,b) for(int i = a; i < b; i++) #define all(A) (A).begin(),(A).end() #define MOD 1000000007 using namespace std; using ll = long long; struct Edge { ll to,cost; }; using Graph = vector>; using P = pair; const ll INF = 1LL<<60; int main() { ll n; cin >> n; int ans = 0; rep(i,100001){ string t = to_string(i+1); string s = t+t+t; if(n >= stoll(s)) ans++; } cout << ans; }