#include <bits/stdc++.h>
using namespace std;
inline void wait(double seconds) {
  double endtime = clock() + (seconds * CLOCKS_PER_SEC);
  while (clock() < endtime) {
    ;
  }
}
template <class T>
inline T fastIn() {
  register char c = 0;
  register T a = 0;
  bool neg = false;
  while (c < 33) c = getchar();
  while (c > 33) {
    if (c == '-') {
      neg = true;
    } else {
      a = (a * 10) + (c - '0');
    }
    c = getchar();
  }
  return neg ? -a : a;
}
inline bool long_overflow(long long a, long long b, string com) {
  unsigned long long max_value = (1ULL << 63) - 1;
  if (com == "plus") {
    return (a > (max_value - b));
  } else {
    assert(b != 0);
    return (a > (max_value / b));
  }
}
set<long long> luckies;
long long upto;
int P, Q;
void dfs1(long long num) {
  if (num > upto) return;
  luckies.insert(num);
  long long nxt_num = (num * 10) + P;
  if (num != nxt_num) dfs1(nxt_num);
  nxt_num = (num * 10) + Q;
  if (num != nxt_num) dfs1(nxt_num);
}
inline void read() {}
inline void proc() {
  upto = fastIn<long long>();
  for (P = 0; P <= 9; ++P) {
    for (Q = 0; Q <= 9; ++Q) {
      dfs1(P);
      dfs1(Q);
    }
  }
  int res = (int)(luckies).size();
  res = max(1, res - 1);
  cout << res << "\n";
}
int main() {
  int kase = 1;
  for (int i = 0, j1 = kase; i < j1; ++i) {
    read();
    proc();
  }
  return 0;
}
