Lamps of the Mind
The great mathematician Arnold spent hours staring at his exciting Abat-Jour. Lamps in it formed a regular polygon. Some of them, with the red light, interested him a lot, other with the blue light less, and some of them didn't interest him at all. His mind chased them, made triangles out of them, memorized and compared those triangles, and after a while triangles forced out of his mind all the rest.
You were hired by a researcher to help unlift the veil over Arnolds genius. It is known that John preferred some colors over others, so there were restrictions on the number of lamps of each color that can be in the considered triangles. Moreover only the geometric form (triangles with the same set length of sides have the same form), but not the position or color of the lamps, was memorized by Arnold. As the first task you have to calculate the number of triangles in the mind of the great mathematician.
Input
The first line of the input contains two integers N and K (3 ≤ N ≤ 3000, 1 ≤ K ≤ N), separated by single space, the number of lamps forming the regular polygon and the number of their colors respectively. The second line contains N integers c_i (1 ≤ c_i ≤ K) separated by single space - colors of the lamps. The third line contains K integers l_i (0 ≤ l_i ≤ 3). They mean that the triangles that have more than l_i lamps of i-th color are not considered by the great mathematician.
Output
Output should contain one integer - the number of geometrically different triangles in the mind of the great mathematician.