#include <bits/stdc++.h>
using namespace std;
int ts, kk = 1, _DB = 1;
inline int LEN(string a) { return a.length(); }
inline int LEN(char a[]) { return strlen(a); }
template <class T>
inline T _abs(T n) {
  return (n < 0 ? -n : n);
}
template <class T>
inline T _max(T a, T b) {
  return (a > b ? a : b);
}
template <class T>
inline T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
inline T _sq(T x) {
  return x * x;
}
template <class T>
inline T _sqrt(T x) {
  return (T)sqrt((double)x);
}
template <class T>
inline T _pow(T x, T y) {
  T z = 1;
  for (int i = 1; i <= y; i++) {
    z *= x;
  }
  return z;
}
template <class T>
inline T _gcd(T x, T y) {
  x = _abs(x);
  y = _abs(y);
  T z = _min(x, y);
  while (x % y) {
    z = x % y;
    x = y;
    y = z;
  }
  return z;
}
template <class T>
inline T _lcm(T x, T y) {
  x = _abs(x);
  y = _abs(y);
  return (x / _gcd(x, y)) * y;
}
template <class T>
inline T getbit(T x, T i) {
  T t = 1;
  return (x & (t << i));
}
template <class T>
inline T setbit(T x, T i) {
  T t = 1;
  return (x | (t << i));
}
template <class T>
inline T resetbit(T x, T i) {
  T t = 1;
  return (x & (~(t << i)));
}
template <class T>
inline T _bigmod(T n, T m) {
  T ans = 1, mult = n % 1000000007;
  while (m) {
    if (m & 1) ans = (ans * mult) % 1000000007;
    m >>= 1;
    mult = (mult * mult) % 1000000007;
  }
  ans %= 1000000007;
  return ans;
}
template <class T>
inline T _modinv(T x) {
  return _bigmod(x, (T)(1000000007 - 2)) % 1000000007;
}
string s;
int sl, dp[(10 + 5)][5][5][(1 << 10) + 2];
int func(int pos, int sm, int zr, int bit) {
  int &ret = dp[pos][sm][zr][bit];
  if (pos == sl) {
    if (zr)
      return ret = 1;
    else
      return ret = 0;
  }
  ret = 0;
  int ts, tz, high, tb;
  if (sm)
    high = 9;
  else
    high = s[pos] - '0';
  for (int i = 0; i <= high; i++) {
    ts = 0;
    if (sm || i < high) ts = 1;
    tz = 0;
    if (zr || i > 0) tz = 1;
    tb = bit;
    if (i == 0) {
      if (!zr) {
        ret += func(pos + 1, ts, tz, tb);
      } else {
        tb = setbit(tb, i);
        if (__builtin_popcount(tb) <= 2) {
          ret += func(pos + 1, ts, tz, tb);
        }
      }
    } else {
      tb = setbit(tb, i);
      if (__builtin_popcount(tb) <= 2) {
        ret += func(pos + 1, ts, tz, tb);
      }
    }
  }
  return ret;
}
int main() {
  cin >> s;
  sl = s.size();
  memset(dp, -1, sizeof dp);
  cout << func(0, 0, 0, 0) << endl;
  return 0;
}
