#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2050;
int n;
char s[MAXN];
int a[MAXN][MAXN];
int bx1[MAXN], by1[MAXN], bx2[MAXN], by2[MAXN];
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) {
      scanf("%s", s);
      for (int j = 0; j < n; j++) a[i][j] = s[j] - '0';
    }
    int ans = 0;
    for (int x0 = 0; x0 + 1 < n; x0++)
      for (int y = n - 1, x = x0; x >= 0; y--, x--)
        if (a[x][y] ^ bx1[x] ^ by1[y]) {
          ans++;
          bx1[x] ^= 1;
          by1[y] ^= 1;
        }
    for (int x0 = n - 1; x0 > 0; x0--)
      for (int x = x0, y = 0; x < n; x++, y++)
        if (a[x][y] ^ bx2[x] ^ by2[y]) {
          ans++;
          bx2[x] ^= 1;
          by2[y] ^= 1;
        }
    for (int i = 0; i < n; i++)
      ans += a[i][i] ^ bx1[i] ^ by1[i] ^ bx2[i] ^ by2[i];
    cout << ans;
  }
}
