#include <bits/stdc++.h>
int n, answer;
int calc(int a) {
  if (a > n) return answer;
  answer++;
  calc(a * 10);
  calc(a * 10 + 1);
  return answer;
}
int main(void) {
  scanf("%d", &n);
  printf("%d\n", calc(1));
  return 0;
}
