#include <bits/stdc++.h>
int main(void) {
  int n, ret = 0, i, j;
  scanf("%d", &n);
  if (n == 1000000000) ++ret, --n;
  for (i = 1; i < 1000000000 && i <= n; i *= 10) {
    int j = i / 10, t = i, c = 0;
    while (j > 0) {
      j /= 10;
      c++;
    }
    j = i / 10;
    while (j > 0) {
      if (t + j <= n) {
        ret += 1 << c - 1;
        t += j;
      }
      j /= 10;
      --c;
    }
    ++ret;
  }
  printf("%d\n", ret);
  return 0;
}
