#include <bits/stdc++.h>
using namespace std;
int n;
char c[2005];
int a[2005][2005];
int p[2005], col[2005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", c);
    for (int j = 0; j < n; j++)
      if (c[j] == '1')
        a[i][j + 1] = 1;
      else
        a[i][j + 1] = 0;
  }
  memset(p, 0, sizeof(p));
  memset(col, 0, sizeof(col));
  int sol = 0;
  for (int i = 1; i <= n; i++) {
    int add = 0;
    for (int j = n; j > i; j--)
      if ((a[i][j] + p[j] + add) % 2) {
        add++;
        p[j]++;
        sol++;
      }
    col[i] += add;
  }
  for (int i = 1; i <= n; i++) col[i] += p[i];
  memset(p, 0, sizeof(p));
  for (int i = n; i >= 1; i--) {
    int add = 0;
    for (int j = 1; j < i; j++)
      if ((a[i][j] + p[j] + add) % 2) {
        add++;
        p[j]++;
        sol++;
      }
    col[i] += add;
  }
  for (int i = 1; i <= n; i++)
    if ((a[i][i] + col[i] + p[i]) % 2) sol++;
  printf("%d\n", sol);
  return 0;
}
