def f(cnt, ind) x = ind.tally.min_of { |elem, c| cnt[elem] // c } ind.each { |i| cnt[i] -= x } x end n = read_line.to_i s = read_line cnt = [s.count('z'), s.count('y'), s.count("v-x"), s.count('u'), s.count("l-t"), s.count('k'), s.count('j'), s.count('i'), s.count("a-h")] puts [ [0], [1, 2], [1, 3, 4], [1, 3, 5, 6], [1, 3, 5, 7, 8], [1, 3, 5, 7, 7], [1, 3, 5, 5], [1, 3, 3], [1, 1], ].sum { |ind| f(cnt, ind) }