#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int prime = 9241;
bool matr[2005][2005];
bool cur[2005][2005];
bool ver[2005], hor[2005], hor0[2005], ver0[2005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    for (int j = 0; j < n; j++) matr[i][j] = tmp[j] == '1';
  }
  int ans = 0;
  for (int i = n - 1; i > 0; i--) {
    int x = i, y = 0;
    for (int j = 0; x + j < n && y + j < n; j++) {
      if (hor[x + j]) cur[x + j][y + j] = !cur[x + j][y + j];
      if (ver[y + j]) cur[x + j][y + j] = !cur[x + j][y + j];
      if (cur[x + j][y + j] != matr[x + j][y + j]) {
        hor[x + j] = !hor[x + j];
        ver[y + j] = !ver[y + j];
        ans++;
      }
    }
  }
  for (int i = n - 1; i > 0; i--) {
    int x = 0, y = i;
    for (int j = 0; x + j < n && y + j < n; j++) {
      if (hor0[x + j]) cur[x + j][y + j] = !cur[x + j][y + j];
      if (ver0[y + j]) cur[x + j][y + j] = !cur[x + j][y + j];
      if (cur[x + j][y + j] != matr[x + j][y + j]) {
        hor0[x + j] = !hor0[x + j];
        ver0[y + j] = !ver0[y + j];
        ans++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (hor0[i]) cur[i][i] = !cur[i][i];
    if (ver0[i]) cur[i][i] = !cur[i][i];
    if (hor[i]) cur[i][i] = !cur[i][i];
    if (ver[i]) cur[i][i] = !cur[i][i];
    if (cur[i][i] != matr[i][i]) ans++;
  }
  cout << ans;
}
