#include <bits/stdc++.h>
using namespace std;
int dp[4][4][2];
int main() {
  string n;
  cin >> n;
  int s = n.size();
  dp[0][0][0] = 1;
  for (long long i = 0; i < (s); i++) {
    for (long long j = 0; j < (4); j++) {
      for (long long k = 0; k < (2); k++) {
        int c_ = n[i] - '0';
        for (long long c = 0; c < (10); c++) {
          int i_ = i + 1;
          int j_ = j;
          int k_ = k;
          if (c != 1) {
            j_++;
          }
          if (k_ == 0) {
            if (c_ < c) {
              continue;
            } else if (c < c_) {
              k_ = 1;
            }
          }
          dp[i_][j_][k_] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[s][0][1] + dp[s][1][1] << endl;
}
