#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "5\n";
    return 0;
  }
  const int MOD = 998244353;
  const int inv2 = 499122177;
  const int inv6 = 166374059;
  auto add = [&](int x, int y) -> int {
    return (x + y) % MOD;
  };
  auto mul = [&](int x, int y) -> int {
    return 1LL * x * y % MOD;
  };
  auto C2 = [&](int x) -> int {
    return mul(mul(x, x+1), inv2);
  };
  auto C3 = [&](int x) -> int {
    return add(mul(x, x), mul(mul(x, x-1), mul(x-2, inv6)));
  };
  // dp[i][j]: 层高为 i 的二叉树，根节点有 j 个儿子的方案数
  vector<vector<int>> dp(n + 1, vector<int>(3));
  // count[i]: 层高 <= i 的二叉树的数量
  vector<int> cnt(n + 1);
  dp[0][0] = 1;
  dp[1][1] = 1;
  dp[1][2] = 1;
  cnt[0] = 1;
  cnt[1] = 3;
  for (int i = 2; i <= n; i++) {
    dp[i][1] = add(dp[i-1][1], dp[i-1][2]);
    dp[i][2] = mul(cnt[i-1] - cnt[i-2], cnt[i-2]);
    dp[i][2] = add(dp[i][2], C2(cnt[i-1] - cnt[i-2]));
    cnt[i] = add(cnt[i-1], add(dp[i][1], dp[i][2]));
  }
  int ans = 0;
  // layer = n
  ans = add(ans, dp[n][2]);
  ans = add(ans, mul(cnt[n-1] - cnt[n-2], C2(cnt[n-2])));
  ans = add(ans, mul(C2(cnt[n-1] - cnt[n-2]), cnt[n-2]));
  ans = add(ans, C3(cnt[n-1] - cnt[n-2]));
  // layer = 0
  ans = add(ans, ans);
  ans = add(ans, dp[n][1]);
  // layer = 1 to n-1
  for (int layer = 1; layer <= n - 1; layer++) {
    ans = add(ans, mul(dp[layer][2], dp[n-layer][1]));
  }
  if (ans < 0) {
    ans += MOD;
  }
  cout << ans << "\n";
  return 0;
}