module ModIntModule export ModInt,+,-,*,/ struct ModInt{n} <: Integer k::UInt64 ModInt{n}(k::Integer) where{n} = new(mod(k,n)) end import Base: +,-,*,/ +(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.k + y.k); -(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(n + x.k - y.k); *(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.k * y.k); /(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.k * invmod(y.k, n)); end using .ModIntModule Base.show(io::IO, a::ModInt{n}) where {n} = show(io, a.k) Base.promote_rule(::Type{ModInt{n}}, ::Type{Int}) where {n} = ModInt{n} Base.convert(::Type{ModInt{n}}, x::Int) where {n} = ModInt{n}(x) const modint998244353 = ModInt{998244353} const modint1000000007 = ModInt{1000000007} using Printf n, m = parse.(Int32, split(readline())) a = ModInt{m}.([1 1;1 0]) f = ModInt{m}.([1;0]) f = (a^(n-2))*f @printf(stdout, "%d\n", f[1].k)