#include <bits/stdc++.h>
using namespace std;
const int INF_MAX = 0x7FFFFFFF;
const int INF_MIN = -(1 << 30);
const double eps = 1e-10;
const double pi = acos(-1.0);
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q) {
  while (!Q.empty()) Q.pop();
}
inline int random(int l, int r) { return rand() % (r - l + 1) + l; }
int dir_4[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
int dir_8[8][2] = {{0, 1},  {-1, 1}, {-1, 0}, {-1, -1},
                   {0, -1}, {1, -1}, {1, 0},  {1, 1}};
long long cnt = 0;
void calc(long long up, long long a, long long b, long long k, bool ja,
          bool jb) {
  for (long long i = 0; i < 2; i++) {
    if (i == 0) {
      long long k1 = 10 * k;
      k1 += a;
      if (k1 > up) continue;
      if (jb) {
        cnt++;
      }
      calc(up, a, b, k1, true, jb);
    } else {
      long long k2 = k * 10;
      k2 += b;
      if (k2 > up) continue;
      if (ja) {
        cnt++;
      }
      calc(up, a, b, k2, ja, true);
    }
  }
}
int main() {
  long long up;
  scanf("%I64d", &up);
  for (int i = 1; i <= 9; i++) {
    for (int j = i + 1; j <= 9; j++) {
      calc(up, i, j, 0, false, false);
    }
  }
  for (int i = 1; i <= 9; i++) {
    if (i <= up) cnt++;
    calc(up, i, 0, i, true, true);
  }
  cout << cnt << endl;
  return 0;
}

### Prompt

Please create a solution in cpp to the following problem:

Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits x and y. For example, if x = 4, and y = 7, then numbers 47, 744, 4 are lucky.

Let's call a positive integer a undoubtedly lucky, if there are such digits x and y (0 ≤ x, y ≤ 9), that the decimal representation of number a (without leading zeroes) contains only digits x and y.

Polycarpus has integer n. He wants to know how many positive integers that do not exceed n, are undoubtedly lucky. Help him, count this number.

Input

The first line contains a single integer n (1 ≤ n ≤ 109) — Polycarpus's number.

Output

Print a single integer that says, how many positive integers that do not exceed n are undoubtedly lucky.

Examples

Input

10


Output

10


Input

123


Output

113

Note

In the first test sample all numbers that do not exceed 10 are undoubtedly lucky.

In the second sample numbers 102, 103, 104, 105, 106, 107, 108, 109, 120, 123 are not undoubtedly lucky.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF_MAX = 0x7FFFFFFF;
const int INF_MIN = -(1 << 30);
const double eps = 1e-10;
const double pi = acos(-1.0);
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q) {
  while (!Q.empty()) Q.pop();
}
inline int random(int l, int r) { return rand() % (r - l + 1) + l; }
int dir_4[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
int dir_8[8][2] = {{0, 1},  {-1, 1}, {-1, 0}, {-1, -1},
                   {0, -1}, {1, -1}, {1, 0},  {1, 1}};
long long cnt = 0;
void calc(long long up, long long a, long long b, long long k, bool ja,
          bool jb) {
  for (long long i = 0; i < 2; i++) {
    if (i == 0) {
      long long k1 = 10 * k;
      k1 += a;
      if (k1 > up) continue;
      if (jb) {
        cnt++;
      }
      calc(up, a, b, k1, true, jb);
    } else {
      long long k2 = k * 10;
      k2 += b;
      if (k2 > up) continue;
      if (ja) {
        cnt++;
      }
      calc(up, a, b, k2, ja, true);
    }
  }
}
int main() {
  long long up;
  scanf("%I64d", &up);
  for (int i = 1; i <= 9; i++) {
    for (int j = i + 1; j <= 9; j++) {
      calc(up, i, j, 0, false, false);
    }
  }
  for (int i = 1; i <= 9; i++) {
    if (i <= up) cnt++;
    calc(up, i, 0, i, true, true);
  }
  cout << cnt << endl;
  return 0;
}

```