Sereja has an *n* × *m* rectangular table *a*, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is, if a component form a rectangle of size *h* × *w*, then the component must contain exactly *hw* cells.

A connected component of the same values is a set of cells of the table that meet the following conditions:
 -  every two cells of the set have the same value; -  the cells of the set form a connected region on the table (two cells are connected if they are adjacent in some row or some column of the table); -  it is impossible to add any cell to the set unless we violate the two previous conditions. 
Can Sereja change the values of at most *k* cells of the table so that the table met the described requirement? What minimum number of table cells should he change in this case?
The first line contains integers *n*, *m* and *k* (1 ≤ *n*, *m* ≤ 100; 1 ≤ *k* ≤ 10). Next *n* lines describe the table *a*: the *i*-th of them contains *m* integers *a*<sub class="lower-index">*i*1</sub>, *a*<sub class="lower-index">*i*2</sub>, ..., *a*<sub class="lower-index">*im*</sub> (0 ≤ *a*<sub class="lower-index">*i*, *j*</sub> ≤ 1) — the values in the cells of the *i*-th row.
# Idea is that all rows are either A or B where A flipped = B (same is true for columns)
#
# Thus, either n and m <= k and since max value of k == 10, we can just brute force all A
#
# Or, n or m > k. WLOG say m <= n.
# Then, if A/B is not one of the existing rows, the number of flips to change each row
# is at least 1 and thus total changes is at least m > k, which is impossible.
#
# Thus, if any A/B yields <= k changes, A/B must be one of the exiting rows.
# (WLOG we can assume A is since if B is, we can just swap A and B
# and this doesn't affect the possible values for the rows = {A, B} obviously)

n, m, k = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]

# In the case of n or m > k, we will be iterating over rows/columns whichever is shorter
# It is easier to iterate over rows, so we transpose if we need to iterate over columns
if m > n:
    b = [[0]*n for i in range(m)]

    for i in range(n):
        for j in range(m):
            b[j][i] = a[i][j]

    a = b
    n, m = m, n


def cost_change(common_row):
    cost = 0

    for row in a:
        diff = 0

        for j, val in enumerate(row):
            diff += common_row[j] != val

        cost += min(diff, (m-diff))

    return cost


ans = k+1

if n > k:
    # row we change to must be a current row (otherwise the cost to change each row must be at least 1, so the total
    # cost is at least m > k, which is impossible

    for row in a:
        ans = min(ans, cost_change(row))
else:
    # row could be anything
    for msk in range(1<<m):
        row = [msk>>k&1 for k in range(m)]

        ans = min(ans, cost_change(row))

print(-1 if ans == k+1 else ans)
