#include <bits/stdc++.h>
using namespace std;
set<long long> squ;
long long n;
bool use[15];
int lenof(int x) {
  int len = 0;
  while (x) {
    len++;
    x /= 10;
  }
  return len;
}
void dfs(long long num, long long x, long long y) {
  if (num > n) return;
  squ.insert(num);
  dfs(num * 10 + x, x, y);
  dfs(num * 10 + y, x, y);
}
int main() {
  cin >> n;
  for (long long i = 0; i <= 9; i++) {
    for (long long j = i + 1; j <= 9; j++) {
      if (i) dfs(i, i, j);
      dfs(j, i, j);
    }
  }
  cout << squ.size() << endl;
  return 0;
}
