#K34652. K-Periodic String Rearrangement

    ID: 25357 Type: Default 1000ms 256MiB

K-Periodic String Rearrangement

K-Periodic String Rearrangement

Given a string (s) and an integer (k), determine whether it is possible to rearrange the characters of (s) to form a k-periodic string. A string is said to be k-periodic if it can be divided into (m) segments each of length (k) (i.e. (n = k \times m), where (n) is the length of (s)) and all segments are identical. Equivalently, for every character in (s), its total frequency must be divisible by (m).

Your task is to read the input from standard input and print the result (either YES or NO) to standard output.

inputFormat

The input consists of two lines. The first line contains a string (s) and the second line contains an integer (k).

outputFormat

Output a single line: YES if the string (s) can be rearranged into a k-periodic string, otherwise NO.## sample

aabb
2
YES

</p>