from string import ascii_uppercase
from math import factorial

_ = input()
string = input()


new_string = string[0]
for i in range(1, len(string)):
    if string[i] >= string[i-1]:
        new_string += string[i]

print(new_string, ascii_uppercase)

ans = 1

for char in ascii_uppercase:
    count = new_string.count(char)

    ans *= count

print(ans % (10**9+7))