#include <bits/stdc++.h>
using namespace std;
int q[15];
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  while (1) {
    q[1] += 1;
    for (int i = 1; i <= 10; i++) {
      if (q[i] == 2) {
        q[i] = 0;
        q[i + 1] += 1;
      }
    }
    int sum = 0;
    for (int i = 1; i <= 10; i++) sum += q[i] * pow(10, i - 1);
    if (sum > n)
      break;
    else
      cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}
