#include <bits/stdc++.h>
using namespace std;
int mp[1000];
int ith_decimal(int x) {
  int n = 0, i = 1;
  while (x != 0) {
    int rem = x % 2;
    x /= 2;
    n += rem * i;
    i *= 10;
  }
  return n;
}
void precal() {
  for (int i = 1; i <= 512; i++) {
    int x = ith_decimal(i);
    mp[i] = x;
  }
}
int main() {
  precal();
  int n;
  cin >> n;
  for (int i = 1; i <= 512; i++) {
    if (mp[i] == n) {
      cout << i << "\n";
      break;
    }
    if (mp[i] > n) {
      cout << i - 1 << "\n";
      break;
    }
  }
}
