T, n = map(int, input().split())
# T = 3, n = 5
for i in range(T):
    game = input().split()
    print(abs(game.count("0") - game.count("1")))