#include <bits/stdc++.h>
using namespace std;
int n, q1[3333], q2[3333], d[3333], ans = 0;
char a[2222][2222];
int main() {
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) gets(a[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] == '1')
        a[i][j] = 1;
      else
        a[i][j] = 0;
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; j--)
      if (a[i][j] ^ q1[i] ^ q2[j]) {
        ans++;
        q1[i] ^= 1;
        q2[j] ^= 1;
        d[i] ^= 1;
        d[j] ^= 1;
      }
  memset(q1, 0, sizeof(q1));
  memset(q2, 0, sizeof(q2));
  for (int i = n - 1; i >= 0; i--)
    for (int j = 0; j < i; j++)
      if (a[i][j] ^ q1[i] ^ q2[j]) {
        ans++;
        q1[i] ^= 1;
        q2[j] ^= 1;
        d[i] ^= 1;
        d[j] ^= 1;
      }
  for (int i = 0; i < n; i++)
    if (a[i][i] ^ d[i]) ans++;
  cout << (ans) << endl;
  return 0;
}
