#include <bits/stdc++.h>
using namespace std;
template <typename T>
T read1() {
  T t = 0;
  char k;
  bool vis = 0;
  do (k = getchar()) == '-' && (vis = 1);
  while ('0' > k || k > '9');
  while ('0' <= k && k <= '9')
    t = (t << 3) + (t << 1) + (k ^ '0'), k = getchar();
  return vis ? -t : t;
}
char str[705];
int s, h[10];
long long P[705][12], C[705][705];
int main() {
  scanf("%s", str + 1);
  s = strlen(str + 1);
  reverse(str + 1, str + s + 1);
  for (int i = 0; i < 12; ++i) P[0][i] = 1;
  for (int i = 1; i <= s; ++i)
    for (int j = 1; j < 12; ++j) P[i][j] = P[i - 1][j] * j % 1000000007;
  for (int i = 0; i <= s; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % 1000000007;
  }
  long long ans = 0;
  for (int i = s; i; --i) {
    str[i] -= '0';
    long long k = 0;
    if (i != s) ++h[str[i + 1]];
    for (int j = 0; j < str[i]; ++j) {
      ++h[j];
      int o = 0;
      for (int l = 10; --l;) {
        o += h[l];
        for (int p = 0; p < i; ++p)
          k = (k + C[i - 1][p] * P[i - p - 1][l] % 1000000007 * P[p][10 - l] %
                       1000000007 * (P[o + p][10] - 1)) %
              1000000007;
        ans = (ans + 111111112ll * k) % 1000000007;
        k = 0;
      }
      --h[j];
    }
  }
  sort(str + 1, str + s + 1);
  long long sum = 0;
  for (int i = 1; i <= s; ++i) sum = (10ll * sum + str[i]) % 1000000007;
  cout << (ans + sum) % 1000000007;
  return 0;
}
