#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n;
bool up[N][N];
bool down[N][N];
bool Left[N][N];
bool Right[N][N];
char s[N][N];
int ans = 0;
void gaoup() {
  for (int d = 1 - n; d < 0; d++) {
    for (int i = 1; i - d <= n; i++) {
      int j = i - d;
      bool mask = false;
      mask ^= up[i][j];
      mask ^= down[i][j];
      mask ^= Left[i][j];
      mask ^= Right[i][j];
      if (up[i][j]) up[i - 1][j] ^= 1;
      if (down[i][j]) down[i + 1][j] ^= 1;
      if (Left[i][j]) Left[i][j - 1] ^= 1;
      if (Right[i][j]) Right[i][j + 1] ^= 1;
      if (mask ^ (s[i][j] == '1')) {
        Left[i][j - 1] ^= 1;
        down[i + 1][j] ^= 1;
        ans++;
      }
    }
  }
}
void gaodown() {
  for (int d = n - 1; d > 0; d--) {
    for (int i = n; i - d >= 1; i--) {
      int j = i - d;
      bool mask = 0;
      mask ^= up[i][j];
      mask ^= down[i][j];
      mask ^= Left[i][j];
      mask ^= Right[i][j];
      if (up[i][j]) up[i - 1][j] ^= 1;
      if (down[i][j]) down[i + 1][j] ^= 1;
      if (Left[i][j]) Left[i][j - 1] ^= 1;
      if (Right[i][j]) Right[i][j + 1] ^= 1;
      if (mask ^ (s[i][j] == '1')) {
        up[i - 1][j] ^= 1;
        Right[i][j + 1] ^= 1;
        ans++;
      }
    }
  }
}
void gaomid() {
  for (int i = 1; i <= n; i++) {
    bool mask = 0;
    mask ^= up[i][i];
    mask ^= down[i][i];
    mask ^= Left[i][i];
    mask ^= Right[i][i];
    if (mask ^ (s[i][i] == '1')) ans++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  gaodown();
  gaoup();
  gaomid();
  cout << ans << endl;
}
