#include <bits/stdc++.h>
using namespace std;
long long int x = 0, y = 0, n;
set<long long int> s;
void dfs(long long int num) {
  if (num > n) return;
  s.insert(num);
  if (!(x == 0 && num == 0)) dfs(num * 10 + x);
  if (!(y == 0 && num == 0)) dfs(num * 10 + y);
}
int main() {
  cin >> n;
  for (x = 0; x <= 9; x++)
    for (y = x; y <= 9; y++) dfs(0ll);
  cout << s.size() - 1 << endl;
}
