He already has quite an impressive collection, and some of them he likes more than the others.
Each chain consists of a certain number of colorful links.
Byteasar has noticed that Bytie's sense of aesthetics is very precise.
It turns out that Bytie finds a contiguous fragment of a chain nice if it contains exactly links of color links of color links of color , and moreover it contains no links of other colors.
A chain's appeal is its number of (contiguous) fragments that are nice.
By trial and error, Byteasar has determined the values and .
Now he would like to buy a new chain, and therefore asks you to write a program to aid him in shopping.