#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 50;
const int maxm = 1e6 + 50;
const double eps = 1e-10;
const int max_index = 62;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
inline int read() {
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
int row[maxn], col[maxn];
char mp[maxn][maxn];
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) {
    scanf("%s", mp[i] + 1);
    for (int j = 1; j <= n; j++) mp[i][j] -= '0';
  }
  int ans = 0;
  for (int i = n; i - 1; i--) {
    for (int j = 1; j < i; j++) {
      if ((mp[i][j] + col[j] + row[i]) & 1) {
        col[j] ^= 1;
        row[i] ^= 1;
        mp[i][i] = 1 - mp[i][i];
        mp[j][j] = 1 - mp[j][j];
        ans++;
      }
    }
  }
  memset(col, 0, sizeof col);
  memset(row, 0, sizeof row);
  for (int i = 1; i < n; i++) {
    for (int j = n; j > i; j--) {
      if ((mp[i][j] + col[j] + row[i]) & 1) {
        col[j] ^= 1;
        row[i] ^= 1;
        ans++;
        mp[i][i] = 1 - mp[i][i];
        mp[j][j] = 1 - mp[j][j];
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (mp[i][i]) ans++;
  printf("%d\n", ans);
  return 0;
}
