#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
char c[MAXN][MAXN];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", c[i]);
  int c_col[MAXN] = {0}, mn[MAXN] = {0}, ans = 0;
  for (int i = 0; i < n; i++) {
    int inv = 0;
    for (int j = n - 1; j >= 0; j--)
      if (i - j < 0) {
        if (c[i][j] - '0' != (c_col[j] ^ inv)) {
          inv ^= 1;
          c_col[j] ^= 1;
          mn[i] ^= 1;
          mn[j] ^= 1;
          ans++;
        }
      }
  }
  memset(c_col, 0, sizeof(c_col));
  for (int i = n - 1; i >= 0; i--) {
    int inv = 0;
    for (int j = 0; j < n; j++) {
      if (i - j > 0) {
        if (c[i][j] - '0' != (c_col[j] ^ inv)) {
          inv ^= 1;
          c_col[j] ^= 1;
          mn[i] ^= 1;
          mn[j] ^= 1;
          ans++;
        }
      }
    }
  }
  for (int i = 0; i < n; i++)
    if (c[i][i] - '0' != mn[i]) ans++;
  printf("%d\n", ans);
  return 0;
}
