#include #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint998244353; mint op(mint x, mint y) {return x + y;} mint e() {return mint::raw(0);} int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; segtree seg(k); seg.set(0, 1); int b = 0; rep(i, n) { mint s = seg.all_prod(); b = (b - 1 + k) % k; seg.set(b, s); } mint ans = mint::raw(2).pow(n) - seg.all_prod(); cout << ans.val() << endl; }