#include <bits/stdc++.h>
using namespace std;
long long n, ans;
int cntTrueBit(int n) {
  int res = 0;
  do {
    res += n & 1;
  } while (n >>= 1);
  return res;
}
void dfs(long long v, int mask) {
  if (v > n) return;
  ++ans;
  int count = cntTrueBit(mask);
  if (count == 2) {
    for (int i = 0; i < 10; ++i)
      if ((mask >> i) & 1) dfs(v * 10ll + i, mask);
  } else if (count == 1) {
    for (int i = 0; i < 10; ++i)
      if ((mask >> i) & 1)
        dfs(v * 10ll + i, mask);
      else
        dfs(v * 10ll + i, mask ^ (1 << i));
  }
}
int main() {
  cin >> n;
  for (long long i = min(n, 9ll); i; --i) dfs(i, 1 << i);
  cout << ans << endl;
  return 0;
}
