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