void main() { import std.stdio, std.string, std.conv, std.algorithm; auto n = readln.chomp.to!(char[]); auto k = readln.chomp.to!(char[]); int s = 0; foreach (c; n) { s = (s * 10 + (c - '0')) % 6; } writeln("428571"[s]); } void rd(T...)(ref T x) { import std.stdio : readln; import std.string : split; import std.conv : to; auto l = readln.split; assert(l.length == x.length); foreach (i, ref e; x) e = l[i].to!(typeof(e)); }