#include <bits/stdc++.h>
using namespace std;
int row, col, k;
int m[100][100];
bool change[100][100];
int main() {
  memset(m, -1, sizeof(m));
  memset(change, false, sizeof(change));
  cin >> row >> col >> k;
  for (int i = 0; i < row; i++)
    for (int j = 0; j < col; j++) cin >> m[i][j];
  int sum = 0;
  for (int i = 1; i < row; i++) {
    int count = 0;
    for (int j = 0; j < col; j++)
      if (m[i][j] != m[0][j]) count++;
    if (count < col - count) {
      for (int j = 0; j < col; j++)
        if (m[i][j] != m[0][j]) {
          change[i][j] = true;
          sum++;
        }
    } else {
      for (int j = 0; j < col; j++)
        if (m[i][j] == m[0][j]) {
          change[i][j] = true;
          sum++;
        }
    }
  }
  bool c1[col];
  memset(c1, false, sizeof(c1));
  for (int i = 1; i < row; i++) {
    for (int j = 0; j < col; j++)
      if (!c1[j]) {
        int count = 0;
        for (int k = 0; k < row; k++)
          if (change[k][j]) count++;
        if (count - (row - count) > 0) {
          sum -= count - (row - count);
          c1[j] = true;
        }
      }
  }
  memset(change, false, sizeof(change));
  int sum2 = 0;
  for (int i = 1; i < row; i++) {
    int count = 0;
    for (int j = 0; j < col; j++)
      if (m[i][j] == m[0][j]) count++;
    if (count < col - count) {
      for (int j = 0; j < col; j++)
        if (m[i][j] == m[0][j]) {
          change[i][j] = true;
          sum2++;
        }
    } else {
      for (int j = 0; j < col; j++)
        if (m[i][j] != m[0][j]) {
          change[i][j] = true;
          sum2++;
        }
    }
  }
  memset(c1, false, sizeof(c1));
  for (int i = 1; i < row; i++) {
    for (int j = 0; j < col; j++)
      if (!c1[j]) {
        int count = 0;
        for (int k = 0; k < row; k++)
          if (change[k][j]) count++;
        if (count - (row - count) > 0) {
          sum2 -= count - (row - count);
          c1[j] = true;
        }
      }
  }
  if (min(sum, sum2) > k)
    cout << -1;
  else
    cout << min(sum, sum2);
  return 0;
}
