#include <bits/stdc++.h>
using namespace std;
int to_dec(int x) {
  int pot = 1;
  int acc = 0;
  while (x) {
    if (x & 1) acc += pot;
    pot *= 10;
    x >>= 1;
  }
  return acc;
}
int solve(int n) {
  int i = 1;
  while (to_dec(i) <= n) ++i;
  return i - 1;
}
int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", solve(n));
}
