N = gets.to_i S = gets.chomp.chars.sort.reverse T = 'yuki' def f(x) completed = Array.new(x, false) idx = 0 5.times do |i| x.times do |j| next if completed[j] return false if N <= idx if T[i] < S[idx] || i == 4 completed[j] = true elsif T[i] == S[idx] # NOOP else return false end idx += 1 end end true end ok = 0 ng = N + 1 while (ok - ng).abs >= 2 x = (ok + ng) / 2 if f(x) ok = x else ng = x end end puts ok