#include <bits/stdc++.h>
using namespace std;
void judge(char x[]) {
  int i = 0;
  while (x[i] && x[i] < '2') {
    ++i;
  }
  while (x[i]) {
    x[i++] = '1';
  }
}
int change(char x[]) {
  judge(x);
  int ans = 0, base = 1;
  for (int i = 0; x[i]; ++i) {
    ans = ans * 2 + x[i] - '0';
  }
  return ans;
}
int main() {
  char x[15];
  scanf("%s", x);
  printf("%d\n", change(x));
  return 0;
}
