#include <bits/stdc++.h>
using namespace std;
long long n, ans = 0;
map<long long, int> m;
void solve(int x, int y, long long curr) {
  long long curr1 = curr * 10 + x;
  long long curr2 = curr * 10 + y;
  if (curr1 <= n && curr1 > 0) {
    if (m[curr1] == 0) ans++;
    m[curr1] = 1;
    solve(x, y, curr1);
  }
  if (curr2 <= n && curr2 > 0) {
    if (m[curr2] == 0) ans++;
    m[curr2] = 1;
    solve(x, y, curr2);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i <= 9; i++) {
    for (int j = i + 1; j <= 9; j++) {
      solve(i, j, 0);
    }
  }
  cout << ans << '\n';
  return 0;
}
