#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
int main() {
  ll a[514], ind = 1;
  a[0] = 0;
  ll n, ans = 0, done = 0;
  cin >> n;
  for (int i = 1; i <= n; i = i * 10) {
    int x = 0;
    while (a[x] < i) {
      a[ind] = i + a[x];
      if (a[ind] <= n)
        ans++;
      else {
        done = 1;
        break;
      }
      ind++;
      x++;
    }
    if (done) break;
  }
  cout << ans;
  return 0;
}
