#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  static int grid[2000][2000];
  static char buf[2100];
  for (int i = 0; i < N; i++) {
    scanf("%s", buf);
    for (int j = 0; j < N; j++) {
      grid[i][j] = buf[j] - '0';
    }
  }
  static int r[2000], c[2000];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j > i; j--) {
      if ((grid[i][j] + r[i] + c[j]) % 2 != 0) {
        ++ans;
        ++r[i];
        ++c[j];
        grid[i][i] = !grid[i][i];
        grid[j][j] = !grid[j][j];
      }
    }
  }
  fill_n(r, N, 0);
  fill_n(c, N, 0);
  for (int i = N - 1; i > 0; i--) {
    for (int j = 0; j < i; j++) {
      if ((grid[i][j] + r[i] + c[j]) % 2 != 0) {
        grid[i][i] = !grid[i][i];
        grid[j][j] = !grid[j][j];
        ++ans;
        ++r[i];
        ++c[j];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (grid[i][i]) {
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}
