#include <bits/stdc++.h>
char s[2001][2001];
int r[2][2001], c[2][2001];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    memset(r, 0, sizeof(r));
    memset(c, 0, sizeof(c));
    int ans = 0;
    for (int i = n - 1; i > 0; i--)
      for (int j = 0; j < i; j++)
        if (((s[i][j] == '1') ^ r[0][i] ^ c[0][j])) {
          r[0][i] ^= 1;
          c[0][j] ^= 1;
          ans++;
        }
    for (int i = 0; i < n - 1; i++)
      for (int j = n - 1; j > i; j--)
        if (((s[i][j] == '1') ^ r[1][i] ^ c[1][j])) {
          r[1][i] ^= 1;
          c[1][j] ^= 1;
          ans++;
        }
    for (int i = 0; i < n; i++)
      if (((s[i][i] == '1') ^ r[1][i] ^ c[1][i] ^ r[0][i] ^ c[0][i])) ans++;
    printf("%d\n", ans);
  }
}
