#include <bits/stdc++.h>
using namespace std;
const int MN = 1000 * 3;
bool grid[MN][MN], br[MN], bc[MN], ur[MN], uc[MN];
int ans, n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) grid[i][j] = s[j] - '0';
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - i - 1; j < i; j++) {
      if (grid[i][j] ^ br[i] ^ bc[j]) {
        ans++;
        br[i] = (br[i] + 1) % 2;
        bc[j] = (bc[j] + 1) % 2;
      }
    }
    for (int j = i - 1; j > (n - i - 1); j--) {
      if (grid[j][n - i - 1] ^ br[j] ^ bc[n - i - 1]) {
        ans++;
        br[j] = (br[j] + 1) % 2;
        bc[n - i - 1] = (bc[n - i - 1] + 1) % 2;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = n - i - 1; j > i; j--) {
      if (grid[i][j] ^ ur[i] ^ uc[j]) {
        ans++;
        uc[j] = (uc[j] + 1) % 2;
        ur[i] = (ur[i] + 1) % 2;
      }
    }
    for (int j = i + 1; j < (n - i - 1); j++) {
      if (grid[j][n - 1 - i] ^ ur[j] ^ uc[n - i - 1]) {
        ans++;
        uc[n - i - 1] = (uc[n - i - 1] + 1) % 2;
        ur[j] = (ur[j] + 1) % 2;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (grid[i][i] ^ uc[i] ^ bc[i] ^ ur[i] ^ br[i]) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
