#include <bits/stdc++.h>
int field[2024][2024], l[2024][2024], r[2024][2024];
int u[2024][2024], d[2024][2024];
int main() {
  int N, ans = 0;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) scanf("%1d", &field[i][j]);
  for (int i = 1; i <= N; i++)
    for (int j = N; j > i; j--) {
      int t = u[i - 1][j] ^ r[i][j + 1] ^ field[i][j];
      u[i][j] = u[i - 1][j];
      r[i][j] = r[i][j + 1];
      if (t) {
        u[i][j] = u[i - 1][j] ^ 1;
        r[i][j] = r[i][j + 1] ^ 1;
        ans++;
      }
    }
  for (int i = N; i >= 1; i--) {
    for (int j = 1; j < i; j++) {
      int t = d[i + 1][j] ^ l[i][j - 1] ^ field[i][j];
      d[i][j] = d[i + 1][j];
      l[i][j] = l[i][j - 1];
      if (t) {
        d[i][j] = d[i + 1][j] ^ 1;
        l[i][j] = l[i][j - 1] ^ 1;
        ans++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    ans += field[i][i] ^ l[i][i - 1] ^ u[i - 1][i] ^ r[i][i + 1] ^ d[i + 1][i];
  printf("%d\n", ans);
}
