cho.sh
Notes
Loading...

Lamps

Time limit

2s

Memory limit

128 MB

Problem

Jimin has an N by M rectangular table with one lamp in each cell. Each lamp is either on or off. There is one switch under each column. Pressing a switch flips the state of every lamp in that column: lamps that were on turn off, and lamps that were off turn on.

A row is called lit if every lamp in that row is on. Jimin will press switches exactly K times. The same switch may be pressed more than once.

After exactly K switch presses, Jimin wants to maximize the number of lit rows. Given the initial lamp states and K, find that maximum possible number.

Input

The first line contains N and M. N is the number of rows, and M is the number of columns. Both are positive integers no greater than 50.

Each of the next N lines contains a string of length M describing one row of lamps. 1 means the lamp is on, and 0 means the lamp is off.

The last line contains K, an integer between 0 and 1,000 inclusive.

Output

Print the maximum number of rows that can be lit after pressing switches exactly K times.