#include <bits/stdc++.h>
const int maxN = 2000 + 2;
int N;
int edg[maxN][maxN];
char str[maxN];
int R[maxN], C[maxN], _R[maxN], _C[maxN];
int main() {
  while (scanf("%d", &N) == 1) {
    for (int i = 0, j; i < N; ++i) {
      scanf("%s", str);
      for (j = 0; str[j]; ++j) edg[i][j] = str[j] - '0';
    }
    int ans = 0;
    memset(R, 0, sizeof(R));
    memset(C, 0, sizeof(C));
    for (int i = 0, j, k; i + 1 < N; ++i)
      for (j = i, k = N - 1; j >= 0; --j, --k)
        if (edg[j][k] ^ R[j] ^ C[k]) ++ans, R[j] ^= 1, C[k] ^= 1;
    memset(_R, 0, sizeof(_R));
    memset(_C, 0, sizeof(_C));
    for (int i = N - 1, j, k; i > 0; --i)
      for (j = i, k = 0; j < N; ++j, ++k)
        if (edg[j][k] ^ _R[j] ^ _C[k]) ++ans, _R[j] ^= 1, _C[k] ^= 1;
    for (int i = 0; i < N; ++i)
      if (edg[i][i] ^ _R[i] ^ R[i] ^ _C[i] ^ C[i]) ++ans;
    printf("%d\n", ans);
  }
  return 0;
}
