#include <bits/stdc++.h>
using namespace std;
char mat[2100][2100];
int col[2100], mid[2100];
int main() {
  int N, i, j;
  while (scanf("%d", &N) != EOF) {
    for (i = 0; i < N; i++) {
      scanf("%s", mat[i]);
      for (j = 0; j < N; j++) mat[i][j] -= '0';
    }
    memset(col, 0, sizeof(col));
    int cnt = 0;
    for (i = N - 1; i >= 1; i--) {
      int last = 0;
      for (j = 0; j < i; j++)
        if ((last ^ col[j] ^ mat[i][j]) == 0)
          ;
        else {
          last = 1 - last;
          col[j] ^= 1;
          cnt++;
        }
      mid[i] = last ^ col[i];
    }
    mid[0] = col[0];
    memset(col, 0, sizeof(col));
    for (i = 0; i < N - 1; i++) {
      int last = 0;
      for (j = N - 1; j > i; j--)
        if ((last ^ col[j] ^ mat[i][j]) == 0)
          ;
        else {
          last ^= 1;
          col[j] ^= 1;
          cnt++;
        }
      mid[i] ^= last ^ col[i];
    }
    mid[N - 1] ^= col[N - 1];
    for (i = 0; i < N; i++) cnt += (mid[i] ^ mat[i][i]);
    printf("%d\n", cnt);
  }
}
