Puppy Parade II
Every dog has its day. While touring the Serengeti, you came across a particularly friendly pack of African wild dogs. As an endangered species, they're worth protecting, so you'd like to fit them with collars to track the pack into the future. There are plenty of dogs, but you have only collars to hand out, the
-th of which has color
and pattern
.
Your task is to choose which collars will be assigned to the dogs. To keep things interesting, each color may be used no more than times, and each pattern may be used no more than
times. What is the maximum number of collars you can use?
Input
The first line contains three integers ,
and
(
), the number of collars you have at your disposal, the maximum number of times you can use a single color, and the maximum number of times you can use a single pattern.
The next lines each contain two strings
and
(
), the color and pattern of the
-th collar. Each color and pattern contains only lowercase English characters.
Output
Output the maximum number of collars you can assign to the dogs.
Example
Input 1
10 3 2
green circle
green circle
green star
green triangle
red star
pink square
pink triangle
gray square
gray star
gray star
Output 1
8
The dogs can wear green collars,
pink collars and
gray collars, so no color is used more than
times. At the same time, they wear
circle collars,
star collars,
square collars and
triangle collars, so no pattern is used more than
times.

Input 2
4 1 1
red circle
red square
blue circle
blue square
Output 2
2
Input 3
6 2 2
red square
red triangle
blue square
blue triangle
green square
green star
Output 3
5
Comments