The Flip Game

Time Limit:1000ms Memory Limit:64000KiB
Accepted:0 Submitted:0
The Flip Game

BOI 99 Day 1 Problem 2

The Flip Game

There is an ancient solitaire game named "the flip game". It consists of an array of M rows and 9 columns of two-colored pegs, with a black and a white side. When a peg with its white side showing is flipped, it shows its black side, and the other way around.

In each move of the game the player flips an entire row or an entire column.

The objective of the game is to leave as few pegs on their black side on the board as possible, by doing any number of moves.

Input

Your program should read the input from the file INPUT.TXT. The first line contains one positive integer number M (1 <= M <= 1000), denoting the number of rows in the game board. The next M consecutive lines contain exactly 9 characters, which are "0"s or "1"s, separated by one space character, where "0" means a peg showing its white side and "1" means a peg showing its black side.

Output

Your program should produce its output into the file OUTPUT.TXT as follows:
There will be only one line of text, containing the minimum possible number of pegs showing their black side, which are left on the game board.

Sample Input

4
1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0

Sample Output

1

Remark

Time Limit per test: 3 seconds
SubmitStatistics

SOJ is designed and developed by Wilbur Ding and Liang Sun. ©All Rights Reserved 2009-2012.