#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int a[N][N];
int b[N], c[N], f[N], t[N];
int main() {
  int n, i, j, k, ans = 0;
  char ch;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      cin >> ch;
      if (ch == '0')
        a[i][j] = 0;
      else
        a[i][j] = 1;
    }
  for (k = n - 1; k >= 1; k--)
    for (i = k + 1; i <= n; i++)
      if ((a[i][i - k] + b[i] + c[i - k]) % 2 != 0) {
        ans++;
        b[i]++;
        f[i]++;
        c[i - k]++;
        f[i - k]++;
      }
  memset(b, 0, sizeof(b));
  memset(c, 0, sizeof(c));
  for (k = n - 1; k >= 1; k--)
    for (i = 1; i <= n - k; i++)
      if ((a[i][i + k] + b[i] + c[i + k]) % 2 != 0) {
        ans++;
        b[i]++;
        f[i]++;
        c[i + k]++;
        f[i + k]++;
      }
  for (i = 1; i <= n; i++)
    if ((a[i][i] + f[i]) % 2 != 0) ans++;
  cout << ans << endl;
}
