#include <bits/stdc++.h>
using namespace std;
long long int M = 1000000007;
long long int n1, n2;
long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    string s;
    cin >> s;
    set<string> ans;
    long long int ll = s.length();
    long long int sum = 0;
    for (long long int l = 1; l < ll + 1; l++) {
      for (long long int a = 48; a < 58; a++) {
        for (long long int b = a; b < 58; b++) {
          for (long long int i = 1; i < l + 1; i++) {
            long long int j = l - i;
            string now;
            for (long long int x = 0; x < i; x++) now += a;
            for (long long int y = 0; y < j; y++) now += b;
            do {
              if (now.length() == s.length()) {
                if (now <= s && now[0] != '0') {
                  ans.insert(now);
                }
              } else if (now.length() < s.length()) {
                if (now[0] != '0') {
                  ans.insert(now);
                }
              }
            } while (next_permutation(now.begin(), now.end()));
          }
        }
      }
    }
    cout << ans.size() << "\n";
  }
  return 0;
}
