#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2222;
int n;
int flip[MAX_N];
int mat[MAX_N][MAX_N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    getchar();
    for (int j = 1; j <= n; ++j) mat[i][j] = getchar() - '0';
  }
  int steps = 0;
  for (int i = 1; i <= n; ++i) {
    int now = 0;
    for (int j = n; j > i; --j) {
      mat[i][j] ^= now;
      mat[i][j] ^= flip[j];
      if (mat[i][j] == 1) {
        mat[i][j] = 0;
        now ^= 1;
        flip[j] ^= 1;
        steps++;
      }
    }
    mat[i][i] ^= now;
  }
  for (int i = 1; i <= n; ++i) {
    mat[i][i] ^= flip[i];
    flip[i] = 0;
  }
  for (int i = n; i >= 1; --i) {
    int now = 0;
    for (int j = 1; j < i; ++j) {
      mat[i][j] ^= now;
      mat[i][j] ^= flip[j];
      if (mat[i][j] == 1) {
        now ^= 1;
        flip[j] ^= 1;
        steps++;
      }
    }
    mat[i][i] ^= now;
  }
  for (int i = 1; i <= n; ++i) steps += mat[i][i] ^ flip[i];
  printf("%d\n", steps);
}
