#include <bits/stdc++.h>
using namespace std;
int a[15];
int sum[15];
void init() {
  a[0] = sum[0] = 1;
  a[1] = 1;
  sum[1] = 1;
  for (int i = 2; i < 15; i++) {
    a[i] = a[i - 1] * 2;
    sum[i] = sum[i - 1] + a[i];
  }
}
int main() {
  char s[15];
  int ans;
  init();
  while (gets(s)) {
    ans = 0;
    int len = strlen(s);
    for (int i = 0; s[i]; i++) {
      if (s[i] > '1') {
        ans += (1 << (len - i)) - 1;
        break;
      }
      if (s[i] == '1') {
        ans += 1 << len - i - 1;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
