#include <bits/stdc++.h>
using namespace std;
int n;
char c;
int a[2010][2010];
int hang[2010], hang2[2010], lie[2010], lie2[2010];
int ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int c = getchar();
      while (c != '0' && c != '1') c = getchar();
      a[i][j] = c - '0';
    }
  for (int i = 1; i <= n; i++) hang[i] = lie[i] = 0;
  for (int sub = n - 1; sub >= 1; sub--) {
    for (int i = n; i >= 2; i--) {
      int j = i - sub;
      if (j < 1 || j > n) continue;
      if (a[i][j] ^ hang[i] ^ lie[j]) {
        ans++;
        hang[i] ^= 1;
        lie[j] ^= 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) hang2[i] = lie2[i] = 0;
  for (int sub = n - 1; sub >= 1; sub--) {
    for (int i = 1; i <= n - 1; i++) {
      int j = sub + i;
      if (j < 1 || j > n) continue;
      if (a[i][j] ^ hang2[i] ^ lie2[j]) {
        ans++;
        hang2[i] ^= 1;
        lie2[j] ^= 1;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (a[i][i] ^ hang[i] ^ hang2[i] ^ lie[i] ^ lie2[i]) ans++;
  printf("%d\n", ans);
  return 0;
}
