import sequtils, strutils let nm = stdin.readLine.split.map parseInt n = nm[0] m = nm[1] var a = 0 b = 1 cnt = 2 while cnt < n: (a, b) = (b, (a + b) mod m) inc cnt echo b