#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int dp[20][3][11][11][2];
int func(int idx = 0, int cur = 0, int n1 = 0, int n2 = 10, bool f = 1) {
  if (idx == n) {
    return 1;
  }
  if (dp[idx][cur][n1][n2][f] != -1) return dp[idx][cur][n1][n2][f];
  int res = 0;
  for (int i = 0; i < 10; i++) {
    bool ff;
    if (!f)
      ff = 0;
    else if (i == s[idx])
      ff = 1;
    else if (i < s[idx])
      ff = 0;
    else
      continue;
    if (i == n1 || i == n2) {
      res += func(idx + 1, cur, n1, n2, ff);
    } else if (cur == 0) {
      res += func(idx + 1, 1, i, n2, ff);
    } else if (cur == 1) {
      res += func(idx + 1, 2, n1, i, ff);
    }
  }
  return dp[idx][cur][n1][n2][f] = res;
}
int main() {
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) s[i] -= '0';
  memset(dp, -1, sizeof dp);
  int res = func() - 1;
  cout << res << endl;
}
