#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const long long INF64 = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
char a[2100][2100];
int need[2100];
int n;
void Load() {
  scanf("%d", &n);
  {
    int c;
    while ((c = getchar()) != 10 && c != EOF)
      ;
  };
  for (int i = 0; i < n; i++) gets(a[i]);
}
void Solve() {
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) a[i][j] -= '0';
  for (int i = 0; i < n; i++) {
    int x = 1;
    for (int j = n - 1; j > i; j--)
      if ((a[i][j] ^ need[j]) == x) {
        a[i][i] ^= 1;
        x ^= 1;
        need[j] ^= 1;
        ans++;
      }
  }
  for (int i = 0; i < n; i++) a[i][i] ^= need[i];
  memset(need, 0, sizeof(need));
  for (int i = n - 1; i >= 0; i--) {
    int x = 1;
    for (int j = 0; j < i; j++)
      if ((a[i][j] ^ need[j]) == x) {
        a[i][i] ^= 1;
        x ^= 1;
        need[j] ^= 1;
        ans++;
      }
  }
  for (int i = 0; i < n; i++) a[i][i] ^= need[i];
  for (int i = 0; i < n; i++) ans += a[i][i];
  cout << ans;
}
int main() {
  Load();
  Solve();
  return 0;
}
