#include <bits/stdc++.h>
using namespace std;
int n, a, b;
set<long long> s;
void dfs(long long x, int a, int b) {
  if (x > 0 && x <= n)
    s.insert(x);
  else
    return;
  if (x > 100000000) return;
  x = x * 10;
  dfs(x + a, a, b);
  dfs(x + b, a, b);
}
int main() {
  cin >> n;
  for (a = 0; a < 10; a++) {
    for (b = 0; b < 10; b++) {
      dfs(a, a, b), dfs(b, a, b);
    }
  }
  cout << s.size();
}
