#include #include #define rep(i, s, n) for (int i = int(s); i < int(n); i++) using mint = atcoder::modint998244353; int main() { int n; std::string x; std::cin >> n >> x; const int m = 11; std::vector dp(m, std::vector(1 << m, std::vector(2, 0))); bool is_top = true; for (auto c : x) { std::vector nxt(m, std::vector(1 << m, std::vector(2, 0))); rep(i, 0, m) { rep(bit, 0, 1 << m) { int ret = 0; rep(j, 0, m) { if ((bit >> j) & 1) { ret |= 1 << ((j * 10) % m); } } rep(d, 0, 10) { int nxt_bit = ret | (1 << i); nxt[(i * 10 + d) % m][nxt_bit][0] += dp[i][bit][0]; if (d < c - '0') { nxt[(i * 10 + d) % m][nxt_bit][0] += dp[i][bit][1]; } else if (d == c - '0') { nxt[(i * 10 + d) % m][nxt_bit][1] += dp[i][bit][1]; } ret <<= 1; if ((ret >> m) & 1) { ret ^= (1 << m) | 1; } } } } rep(i, 1, 10) { if (is_top) { if (i == c - '0') nxt[i][1][1]++; else if (i < c - '0') nxt[i][1][0]++; else continue; } else nxt[i][1][0]++; } dp = nxt; is_top = false; } mint ans = 0; rep(bit, 0, 1 << m) { if (bit & 1) continue; ans += dp[0][bit][0] + dp[0][bit][1]; } std::cout << ans.val() << '\n'; }