#include <bits/stdc++.h>
using namespace std;
int n, data[2005][2005], now[2005][2005];
int main() {
  scanf("%d", &n);
  char s[2005];
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    for (int j = 1; j <= n; j++) data[i][j] = s[j - 1] - '0';
  }
  int ans = 0;
  int l[2005], r[2005], m[2005];
  memset(l, 0, sizeof(l));
  memset(r, 0, sizeof(r));
  memset(m, 0, sizeof(m));
  for (int i = 1; i <= n; i++) {
    for (int j = n; j > i; j--) {
      if ((l[j] + r[i]) % 2 != data[i][j]) {
        l[j]++;
        r[i]++;
        ans++;
      }
    }
  }
  for (int i = 1; i <= n; i++) m[i] = l[i] + r[i];
  memset(l, 0, sizeof(l));
  memset(r, 0, sizeof(r));
  for (int j = 1; j <= n; j++)
    for (int i = n; i > j; i--) {
      if ((l[j] + r[i]) % 2 != data[i][j]) {
        l[j]++;
        r[i]++;
        ans++;
      }
    }
  for (int i = 1; i <= n; i++) m[i] += l[i] + r[i];
  for (int i = 1; i <= n; i++)
    if (m[i] % 2 != data[i][i]) ans++;
  printf("%d\n", ans);
  return 0;
}
