#include <iostream>
#include <vector>
#include <map>

#include <atcoder/modint>

using namespace std;

using mint = atcoder::static_modint<998244353>;

int main () {
    // 選択肢は最後に伸びた方向に依存する。
    // 最後に伸びた方向がわかっているとき、残り1日で増える高さの期待値はすぐわかるので、ここからさかのぼっていく感じでこたえることが出来そう。

    int N; cin >> N;

    map<pair<int, int>, mint> memo;

    auto dp = [&] (auto&& dp, int last, int remain) {
        auto key = make_pair(last, remain);
        if (memo.find(key) != memo.end()) return memo[key];
        if (remain == 0) return mint(0);

        mint res = 0;

        if (last == 0) {
            res = dp(dp, 0, remain - 1) / 2 + (dp(dp, 1, remain - 1) + 1) / 2;
        }

        if (last == 1) {
            res = dp(dp, 0, remain - 1) / 3 + (dp(dp, 1, remain - 1) + 1) / 3 + (dp(dp, 2, remain - 1) + 1) / 3;
        }

        if (last == 2) {
            res = 2 * (dp(dp, 1, remain - 1) + 1) / 3 + (dp(dp, 2, remain - 1) + 1) / 3;
        }

        return memo[key] = res;
    };

    // 最初の一手だけ自由度が高い。
    mint ans = 0;
    ans = (dp(dp, 2, N - 1) + 1) / 5 + 2 * dp(dp, 0, N - 1) / 5 + 2 * (dp(dp, 1, N - 1) + 1) / 5;

    cout << ans.val() << "\n";
}