static object Solve() { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine(); var t = Console.ReadLine(); var tr = string.Join("", t.Select(c => c == 'G' ? 'B' : c == 'B' ? 'G' : c)); var tg = string.Join("", t.Select(c => c == 'B' ? 'R' : c == 'R' ? 'B' : c)); var tb = string.Join("", t.Select(c => c == 'R' ? 'G' : c == 'G' ? 'R' : c)); var sr = new RH(s); var trr = new RH(tr); var trg = new RH(tg); var trb = new RH(tb); var c = 0; for (var(i, j) = (-(n - 1), n - 1); i < n; i++, j--) { var sh = sr.Hash2(Math.Max(0, i), Math.Min(n, i + n)); var(l, r) = (Math.Max(0, j), Math.Min(n, j + n)); if (sh == trr.Hash2(l, r) || sh == trg.Hash2(l, r) || sh == trb.Hash2(l, r)) { c++; } } return(c); }