Making Lunch Boxes

Given binary recipe vectors, choose the largest subset with every ingredient appearing in an even number of chosen recipes, meaning their XOR is zero.

Hard8MathBit manipulationGreedyNo attempts yetTime limit8sMemory limit512 MB

Problem

Taro has been hooked on making lunch boxes lately. He got a new lunch box recipe book today, and he wants to try as many of the recipes in it as he can in one day.

He has plenty of every ingredient, but they all come in vacuum packs of two. If he opens a pack, uses one piece and leaves the other, the leftover goes bad quickly. Making two lunch boxes from the same recipe is no fun. So Taro decided to pick a set of recipes that are all different and leave no ingredient unused. An ingredient is used up pack by pack exactly when the number of chosen recipes that need it is even.

The book may list different recipes that call for the same set of ingredients. Those still count as different recipes.

He may pick no recipe at all, and then the answer is 0. How many recipes can Taro try today at most?

Input

The input consists of at most 50 datasets, each in the following format.

n m
b1,1...b1,m
...
bn,1...bn,m

The first line contains nn, the number of recipes listed in the book, and mm, the number of ingredients. Both nn and mm are positive integers with 1n5001 \le n \le 500, 1m5001 \le m \le 500 and 1n×m5001 \le n \times m \le 500. Each of the next nn lines describes one recipe as a string of length mm made of 0 and 1. If bi,jb_{i,j} is 1, the ii-th recipe needs the jj-th ingredient, and if it is 0, it does not. Every such line contains at least one 1.

The end of the input is a line containing two zeros.

Output

For each dataset, print the maximum number of recipes Taro can try, one per line.