#include <bits/stdc++.h>
using namespace std;
int n;
char s[2005][2005];
int vis[2005][2005];
int r[2005], c[2005], a[2005];
queue<pair<int, int> > q;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, 1, -1, 0};
int ans = 0;
void bfs1() {
  q.push(make_pair(n, 1));
  vis[n][1] = 1;
  while (!q.empty()) {
    int kx = q.front().first;
    int ky = q.front().second;
    q.pop();
    if (kx == ky) continue;
    if (r[kx] ^ c[ky] != s[kx][ky] - '0') {
      ans++;
      r[kx] ^= 1;
      c[ky] ^= 1;
      a[kx] ^= 1;
      a[ky] ^= 1;
    }
    for (int i = 0; i < 2; ++i) {
      int tx = dx[i] + kx, ty = dy[i] + ky;
      if (vis[tx][ty]) continue;
      vis[tx][ty] = 1;
      q.push(make_pair(tx, ty));
    }
  }
}
void bfs2() {
  memset(r, 0, sizeof(r));
  memset(c, 0, sizeof(c));
  q.push(make_pair(1, n));
  vis[1][n] = 1;
  while (!q.empty()) {
    int kx = q.front().first;
    int ky = q.front().second;
    q.pop();
    if (kx == ky) {
      continue;
    }
    if (r[kx] ^ c[ky] != s[kx][ky] - '0') {
      ans++;
      r[kx] ^= 1;
      c[ky] ^= 1;
      a[kx] ^= 1;
      a[ky] ^= 1;
    }
    for (int i = 2; i < 4; ++i) {
      int tx = kx + dx[i], ty = ky + dy[i];
      if (vis[tx][ty]) continue;
      vis[tx][ty] = 1;
      q.push(make_pair(tx, ty));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i] + 1);
  }
  bfs1();
  bfs2();
  for (int i = 1; i <= n; ++i) {
    if (a[i] != s[i][i] - '0') {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
