using System; using System.Collections.Generic; using static System.Console; using System.Linq; class yuki321 { static int NN => int.Parse(ReadLine()); static string[] SList(int n) => Enumerable.Repeat(0, n).Select(_ => ReadLine()).ToArray(); static void Main() { var n = ReadLine(); var list = new List(); foreach (var ni in n) { list.AddRange(ToBin(ni - 'A' + 10)); } var counts = new int[8]; for (var e = list.Count; e > 0; e -= 3) { var s = Math.Max(0, e - 3); ++counts[FromBin(list.Skip(s).Take(e - s).ToList())]; } var res = new List(); var maxcount = counts.Max(); for (var i = 0; i < counts.Length; ++i) if (counts[i] == maxcount) res.Add(i); WriteLine(string.Join(" ", res)); } static List ToBin(int a) { var list = new List(); var tmp = a; for (var i = 0; i < 4; ++i) { list.Add(tmp % 2); tmp >>= 1; } list.Reverse(); return list; } static int FromBin(List list) { var num = 0; foreach (var li in list) { num <<= 1; num += li; } return num; } }