#include <bits/stdc++.h>
using namespace std;
set<int> exist;
int i, j, N;
void gen(long long now, int dep) {
  if (dep > 10) return;
  if (now > (long long)N) return;
  exist.insert(now);
  gen(now * 10 + i, dep + 1);
  gen(now * 10 + j, dep + 1);
}
int main() {
  cin >> N;
  for (i = 0; i <= 9; i++)
    for (j = i + 1; j <= 9; j++) gen(0, 0);
  cout << exist.size() - 1;
  return 0;
}
