#include <bits/stdc++.h>
using namespace std;
int n, ans;
char s[2020];
int a[2020][2020];
int vis[2020], vis2[2020], vis3[3202], vis4[3202];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    for (int j = 1; j <= n; j++) a[i][j] = s[j - 1] - '0';
  }
  for (int i = 1; i <= n; i++) {
    for (int j = n; j > i; j--) {
      if (a[i][j] && vis[i] + vis2[j] != 1)
        vis[i] ^= 1, vis2[j] ^= 1, ans++;
      else if (a[i][j] == 0 && vis[i] + vis2[j] == 1)
        vis[i] ^= 1, vis2[j] ^= 1, ans++;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j < i; j++) {
      if (a[i][j] && vis3[i] + vis4[j] != 1)
        vis3[i] ^= 1, vis4[j] ^= 1, ans++;
      else if (a[i][j] == 0 && vis3[i] + vis4[j] == 1)
        vis3[i] ^= 1, vis4[j] ^= 1, ans++;
    }
  }
  for (int i = 1; i <= n; i++)
    if ((vis[i] + vis2[i] + vis3[i] + vis4[i]) % 2 && a[i][i] == 0)
      ans++;
    else if ((vis[i] + vis2[i] + vis3[i] + vis4[i]) % 2 == 0 && a[i][i] == 1)
      ans++;
  printf("%d\n", ans);
  return 0;
}
