Problem: Let's call a fraction x/y good if there exists at least one another fraction (x')/(y') such that x/y = (x')/(y'), 1 ≤ x', y' ≤ 9, the digit denoting x' is contained in the decimal representation of x, and the digit denoting y' is contained in the decimal representation of y. For example, 26/13 is a good fraction, because 26/13 = 2/1.

You are given an integer number n. Please calculate the number of good fractions x/y such that 1 ≤ x ≤ n and 1 ≤ y ≤ n. The answer may be really large, so print it modulo 998244353.

Input

The only line of the input contains one integer n (1 ≤ n < 10^{100}).

Output

Print the number of good fractions x/y such that 1 ≤ x ≤ n and 1 ≤ y ≤ n. The answer may be really large, so print it modulo 998244353.

Examples

Input


42


Output


150


Input


3141592653589793238462643383279


Output


459925407

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
class pa3 {
 public:
  long long x;
  long long y, z;
  pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
  bool operator<(const pa3& p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    return z < p.z;
  }
  bool operator>(const pa3& p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    return z > p.z;
  }
  bool operator==(const pa3& p) const {
    return x == p.x && y == p.y && z == p.z;
  }
  bool operator!=(const pa3& p) const {
    return !(x == p.x && y == p.y && z == p.z);
  }
};
class pa4 {
 public:
  long long x;
  long long y, z, w;
  pa4(long long x = 0, long long y = 0, long long z = 0, long long w = 0)
      : x(x), y(y), z(z), w(w) {}
  bool operator<(const pa4& p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return w < p.w;
  }
  bool operator>(const pa4& p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    if (z != p.z) return z > p.z;
    return w > p.w;
  }
  bool operator==(const pa4& p) const {
    return x == p.x && y == p.y && z == p.z && w == p.w;
  }
};
class pa2 {
 public:
  long long x, y;
  pa2(long long x = 0, long long y = 0) : x(x), y(y) {}
  pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); }
  pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); }
  bool operator<(const pa2& p) const { return y != p.y ? y < p.y : x < p.x; }
  bool operator>(const pa2& p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const pa2& p) const {
    return abs(x - p.x) == 0 && abs(y - p.y) == 0;
  }
  bool operator!=(const pa2& p) const {
    return !(abs(x - p.x) == 0 && abs(y - p.y) == 0);
  }
};
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long Gcd(long long v, long long b) {
  if (v == 0) return b;
  if (b == 0) return v;
  if (v > b) return Gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return Gcd(v, b % v);
}
long long mod;
long long extgcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
pair<long long, long long> operator+(const pair<long long, long long>& l,
                                     const pair<long long, long long>& r) {
  return {l.first + r.first, l.second + r.second};
}
pair<long long, long long> operator-(const pair<long long, long long>& l,
                                     const pair<long long, long long>& r) {
  return {l.first - r.first, l.second - r.second};
}
ostream& operator<<(ostream& os, const vector<long long>& VEC) {
  for (auto v : VEC) os << v << " ";
  return os;
}
ostream& operator<<(ostream& os, const pair<long long, long long>& PAI) {
  os << PAI.first << " : " << PAI.second;
  return os;
}
ostream& operator<<(ostream& os, const pa3& PAI) {
  os << PAI.x << " : " << PAI.y << " : " << PAI.z;
  return os;
}
ostream& operator<<(ostream& os, const pa4& PAI) {
  os << PAI.x << " : " << PAI.y << " : " << PAI.z << " : " << PAI.w;
  return os;
}
ostream& operator<<(ostream& os,
                    const vector<pair<long long, long long> >& VEC) {
  for (auto v : VEC) os << v << " ";
  return os;
}
long long beki(long long wa, long long rr, long long warukazu) {
  if (rr == 0) return 1 % warukazu;
  if (rr == 1) return wa % warukazu;
  wa %= warukazu;
  if (rr % 2 == 1)
    return ((long long)beki(wa, rr - 1, warukazu) * (long long)wa) % warukazu;
  long long zx = beki(wa, rr / 2, warukazu);
  return (zx * zx) % warukazu;
}
long long pr[1100000];
long long inv[1100000];
long long comb(long long nn, long long rr) {
  if (rr < 0 || rr > nn || nn < 0) return 0;
  long long r = pr[nn] * inv[rr];
  r %= mod;
  r *= inv[nn - rr];
  r %= mod;
  return r;
}
void gya(long long ert) {
  pr[0] = 1;
  for (long long i = 1; i <= ert; i++) {
    pr[i] = ((long long)pr[i - 1] * i) % mod;
  }
  inv[ert] = beki(pr[ert], mod - 2, mod);
  for (long long i = ert - 1; i >= 0; i--) {
    inv[i] = (long long)inv[i + 1] * (i + 1) % mod;
  }
}
long long dp[110][10][10][2][16][16] = {};
void sh(long long p) {
  for (long long z = 0; z < 2; z++)
    for (long long i = 0; i <= 109; i++)
      for (long long a = 0; a < 10; a++)
        for (long long b = 0; b < 10; b++)
          for (long long x = 0; x < p; x++)
            for (long long y = 0; y < p; y++) {
              dp[i][a][b][z][x][y] = 0;
            }
}
void solve() {
  string S;
  cin >> S;
  mod = 998244353;
  long long ans2 = 0, ans = 0;
  for (auto c : S) {
    ans2 *= 10;
    ans2 += c - '0';
    ans2 %= mod;
  }
  long long n = S.length();
  S = "00" + S;
  reverse(S.begin(), S.end());
  for (long long s = 1; s < 10; s++)
    for (long long t = s + 1; t < 10; t++)
      if (Gcd(s, t) == 1) {
        long long ju1[10];
        long long ju2[10];
        for (long long i = 0; i < 10; i++) ju2[i] = -1, ju1[i] = -1;
        long long ff = 0;
        for (long long k = 1; k * t < 10; k++) {
          ju1[k * s] = k - 1;
          ju2[k * t] = k - 1;
          ff++;
        }
        sh((1 << ff));
        dp[0][0][0][0][0][0] = 1;
        for (long long i = 0; i <= n + 1; i++)
          for (long long a = 0; a < 10; a++)
            for (long long b = 0; b < 10; b++)
              for (long long x = 0; x < (1 << ff); x++)
                for (long long y = 0; y < (1 << ff); y++) {
                  for (long long f = 0; f < 2; f++)
                    if (dp[i][a][b][f][x][y]) {
                      for (long long j = 0; j < 10; j++) {
                        long long B = b + j * t;
                        long long A = a + j * s;
                        long long BB = B % 10;
                        long long AA = A % 10;
                        long long BBB = B / 10;
                        long long AAA = A / 10;
                        long long p = 0;
                        if (ju1[AA] >= 0) p = 1 << ju1[AA];
                        long long q = 0;
                        if (ju2[BB] >= 0) q = 1 << ju2[BB];
                        long long Z;
                        if (f == 0) {
                          if (S[i] - '0' >= B % 10)
                            Z = 0;
                          else
                            Z = 1;
                        } else {
                          if (S[i] - '0' > B % 10)
                            Z = 0;
                          else
                            Z = 1;
                        }
                        dp[i + 1][AAA][BBB][Z][x | p][y | q] +=
                            dp[i][a][b][f][x][y];
                        if (dp[i + 1][AAA][BBB][Z][x | p][y | q] >= mod)
                          dp[i + 1][AAA][BBB][Z][x | p][y | q] -= mod;
                      }
                    }
                }
        for (long long x = 0; x < (1 << ff); x++)
          for (long long y = 0; y < (1 << ff); y++)
            if (x & y) {
              ans += dp[n + 1][0][0][0][x][y];
              if (ans >= mod) ans -= mod;
            }
      }
  cout << (ans * 2 + ans2) % mod << endl;
}
signed main() {
  mod = 1000000007;
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n = 1;
  for (long long i = 0; i < n; i++) solve();
  return 0;
}