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