#include <bits/stdc++.h>
using namespace std;
set<long long> s;
void dfs(int a, int b, long long sum, int d, int& n) {
  if (d >= 0) {
    if (sum <= n && sum > 0) {
      s.insert(sum);
    }
  }
  if (d == 0) {
    return;
  }
  dfs(a, b, sum * 10 + a, d - 1, n);
  dfs(a, b, sum * 10 + b, d - 1, n);
}
int main() {
  int n;
  cin >> n;
  int c = 0, nn = n;
  while (nn) {
    nn /= 10;
    ++c;
  }
  for (int i = 0; i <= 9; ++i) {
    for (int j = i + 1; j <= 9; ++j) {
      dfs(i, j, 0, c, n);
    }
  }
  cout << s.size() << endl;
}
