#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, inf = 1e9 + 10, MOD = 1e9 + 7, Sq = 708;
const long long INF = 1e18 + 10;
map<int, bool> mark;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, x, t = 0, ans = 0;
  cin >> n;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < (1 << 10); k++) {
        t = 0;
        for (int p = 0; (1 << p) <= k; p++) {
          t *= 10;
          if ((1 << p) & k)
            t += j;
          else
            t += i;
        }
        if (t <= n && t > 0 && !mark[t]) ans++, mark[t] = true;
      }
    }
  }
  cout << ans;
  return 0;
}
