#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2000;
int N;
int board[MAX_N][MAX_N];
int cur[MAX_N][MAX_N];
int row[MAX_N], col[MAX_N];
char buf[MAX_N + 10];
void pb(int arr[MAX_N][MAX_N]) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      printf("%d", arr[i][j]);
    }
    puts("");
  }
}
int solve() {
  int ans = 0;
  for (int i = N - 1; i > 0; i--) {
    for (int j = 0; j < N - i; j++) {
      int y = i + j, x = j;
      cur[y][x] = row[y] ^ col[x];
      if (cur[y][x] ^ board[y][x]) {
        ans++;
        cur[y][x] ^= 1;
        row[y] ^= 1;
        col[x] ^= 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (col[i] ^ row[i]) {
      board[i][i] ^= 1;
    }
  }
  memset(col, 0, sizeof(col));
  memset(row, 0, sizeof(row));
  for (int j = N - 1; j > 0; j--) {
    for (int i = 0; i < N - j; i++) {
      int y = i, x = j + i;
      cur[y][x] = row[y] ^ col[x];
      if (cur[y][x] ^ board[y][x]) {
        ans++;
        cur[y][x] ^= 1;
        row[y] ^= 1;
        col[x] ^= 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (row[i] ^ col[i] ^ board[i][i]) {
      ans++;
    }
  }
  return ans;
}
int main() {
  scanf(" %d ", &N);
  for (int i = 0; i < N; i++) {
    scanf(" %s ", buf);
    for (int j = 0; j < N; j++) {
      board[i][j] = buf[j] & 1;
    }
  }
  printf("%d\n", solve());
  return 0;
}
