#include <bits/stdc++.h>
using namespace std;
set<long long> kopa;
int n, x, y;
void meow(long long skaitlis, long c) {
  if (skaitlis > n || c > 10) return;
  kopa.insert(skaitlis);
  meow(10 * skaitlis + x, c + 1);
  meow(10 * skaitlis + y, c + 1);
}
int main() {
  cin >> n;
  for (x = 0; x < 10; x++) {
    for (y = x + 1; y < 10; y++) {
      meow(0, 0);
    }
  }
  cout << kopa.size() - 1 << "\n";
  return 0;
}
