import strutils proc input: string = while true: let t = stdin.readChar if t.isSpaceAscii: break else: result.safeAdd t let N, M = input().parseInt var nw, pst: int for i in 1 .. N: if i <= 2: nw = i - 1 pst = 0 else: swap(pst, nw) nw += pst nw = nw mod M echo nw