#include <bits/stdc++.h>
using namespace std;
char c[2005][2005];
int a[2005][2005], L[2005][2005], D[2005][2005], R[2005][2005], U[2005][2005];
int main() {
  int sol = 0, n;
  scanf("%d", &n);
  getchar();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      c[i][j] = getchar();
      a[i][j] = c[i][j] - '0';
    }
    getchar();
  }
  int cnt = n;
  for (int i = 1; i <= n - 1; i++) {
    cnt--;
    int x = 1, y = 1 + cnt;
    while (y <= n) {
      if ((a[x][y] + L[x][y] + D[x][y]) % 2 == 1) {
        a[x][y] = 0;
        L[x][y - 1]++;
        D[x + 1][y]++;
        sol++;
      }
      L[x][y - 1] += L[x][y];
      D[x + 1][y] += D[x][y];
      if ((a[y][x] + U[y][x] + R[y][x]) % 2 == 1) {
        a[y][x] = 0;
        U[y - 1][x]++;
        R[y][x + 1]++;
        sol++;
      }
      R[y][x + 1] += R[y][x];
      U[y - 1][x] += U[y][x];
      y++;
      x++;
    }
  }
  for (int i = 1; i <= n; i++)
    sol += (a[i][i] + D[i][i] + U[i][i] + L[i][i] + R[i][i]) % 2;
  printf("%d\n", sol);
  return 0;
}
