#include <bits/stdc++.h>
using namespace std;
int n, a[2005][2005], d1[2005][4200], d2[2005][4200], l, r, ans, N;
char s[2005];
void update1(int k, int l) {
  int k2 = k;
  k += N;
  while (k > 0) {
    a[k2][l] ^= d1[l][k];
    k /= 2;
  }
}
void update2(int k, int l) {
  int l2 = l;
  l += N;
  while (l > 0) {
    a[k][l2] ^= d2[k][l];
    l /= 2;
  }
}
void invert1(int v, int ll, int rr, int k) {
  if (l > rr || r < ll) return;
  if (l <= ll && r >= rr) {
    d1[k][v] ^= 1;
    return;
  }
  int mm = (ll + rr) / 2;
  invert1(2 * v, ll, mm, k);
  invert1(2 * v + 1, mm + 1, rr, k);
}
void invert2(int v, int ll, int rr, int k) {
  if (l > rr || r < ll) return;
  if (l <= ll && r >= rr) {
    d2[k][v] ^= 1;
    return;
  }
  int mm = (ll + rr) / 2;
  invert2(2 * v, ll, mm, k);
  invert2(2 * v + 1, mm + 1, rr, k);
}
int main() {
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    gets(s);
    for (int j = 0; j < n; j++) a[i][j] = s[j] - '0';
  }
  N = 2048;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    for (int j = i + 1; j < n; j++) {
      update1(i, j);
      update2(i, j);
      update1(j, i);
      update2(j, i);
    }
    for (int j = n - 1; j > i; j--)
      if (a[i][j] + a[i][j + 1] == 1) {
        ans++;
        l = i;
        r = j;
        invert1(1, 0, N - 1, j);
        tmp++;
      }
    for (int j = n - 1; j > i; j--)
      if (a[j][i] + a[j + 1][i] == 1) {
        ans++;
        l = i;
        r = j;
        invert2(1, 0, N - 1, j);
        tmp++;
      }
    update1(i, i);
    update2(i, i);
    if ((a[i][i] + tmp) % 2 == 1) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
