#C454. Nth Most Frequent Character

    ID: 48089 Type: Default 1000ms 256MiB

Nth Most Frequent Character

Nth Most Frequent Character

Given a string S consisting of lowercase letters and an integer N, your task is to determine the N-th most frequent character in the string.

The frequency of each character is determined, and the characters are ranked primarily by descending frequency. In the case where two characters have the same frequency, the lexicographically smaller character is considered to have a higher rank.

If the N-th most frequent character does not exist, print an empty string.

Example: In the string hello, the character 'l' appears twice, whereas 'e', 'h', and 'o' appear only once. Among the characters with frequency 1, 'e' is lexicographically smallest, so the ranking would be: 1st: 'l', 2nd: 'e', 3rd: 'h', 4th: 'o'.

inputFormat

The input is read from standard input and consists of two lines:

  1. The first line contains the string S (which may be empty) composed of lowercase English letters.
  2. The second line contains an integer N.

outputFormat

Print a single character to standard output: the N-th most frequent character in the given string. If no such character exists, output an empty line.

## sample
aabbcc
2
b

</p>