using static System.Math; using System; public class Hello { public static void Main() { var s = Console.ReadLine().Trim(); var t = Console.ReadLine().Trim(); var s2 = check6(s); var t2 = check6(t); var a = (int)Pow(s2, t2) % 6; Console.WriteLine("428571"[a]); } public static int check6(string s) { if (s.Length == 1) return int.Parse(s) % 6; var sum = 0L; var sL = s.Length; for (int i = 0; i < sL - 1; i++) sum += s[i] - '0'; var b = s[sL - 1] - '0'; for (int i = 0; i <= 9; i++) if (((sum + i) % 3 == 0) && i % 2 == 0 ) { if (b - i < 0) return b - i + 6; else return (b - i) % 6; } return 0; } }