@staticmethod
def b_2():
    (n, s) = sys.stdin.read().split()
    n = int(n)
    if ((n & 1) ^ 1):
        print((- 1))
        return
    a = list('abc')
    i = ((1 - (n // 2)) % 3)
    for c in s:
        if (c != a[i]):
            print((- 1))
            return
        i = ((i + 1) % 3)
    print((n // 2))
@staticmethod
def b_2():
    (n, s) = sys.stdin.read().split()
    n = int(n)
    if ((n & 1) ^ 1):
        print((- 1))
        return
    a = list('abc')
    i = ((1 - (n // 2)) % 3)
    for c in s:
        if (c != a[i]):
            print((- 1))
            return
        i = ((i + 1) % 3)
    print((n // 2))