#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const long long inf = (1LL << 61) - 1;
const int mod = 998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string n;
    cin >> n;

    vector<vector<vector<long long>>> dp(2, vector<vector<long long>>(2, vector<long long>(1024, 0)));
    dp[0][0][0] = 1;

    for (int i = 0; i < n.size(); ++i) {
        vector<vector<vector<long long>>> e(2, vector<vector<long long>>(2, vector<long long>(1024, 0)));
        for (int lessflag = 0; lessflag < 2; ++lessflag) {
            for (int zeroflag = 0; zeroflag < 2; ++zeroflag) {
                for (int bit = 0; bit < 1024; ++bit) {
                    for (int x = 0; x < 10; ++x) {
                        if (lessflag == 0 && x > n[i] - '0') continue;
                        int tlessflag = lessflag | (x < n[i] - '0');
                        int tzeroflag = zeroflag | (x > 0);
                        if (tzeroflag == 0) {
                            e[tlessflag][tzeroflag][bit] += dp[lessflag][zeroflag][bit];
                            e[tlessflag][tzeroflag][bit] %= mod;
                        } else {
                            e[tlessflag][tzeroflag][bit ^ (1 << x)] += dp[lessflag][zeroflag][bit];
                            e[tlessflag][tzeroflag][bit ^ (1 << x)] %= mod;
                        }
                    }
                }
            }
        }
        dp = e;
    }

    int c = 0;
    for (char v : n) {
        c ^= 1 << (v - '0');
    }
    if (c == 0) {
        dp[1][1][0] += 1;
    }
    cout << dp[1][1][0] % mod << "\n";

    return 0;
}