module ModIntModule export ModInt,+,-,*,/ struct ModInt{n} <: Integer value::UInt64 ModInt{n}(value::Integer) where{n} = new(mod(value,n)) end import Base: +,-,*,/ +(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.value + y.value); -(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(n + x.value - y.value); *(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.value * y.value); /(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.value * invmod(y.value, n)); end using .ModIntModule Base.show(io::IO, a::ModInt{n}) where {n} = show(io, a.value) 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].value)