#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
int main() {
  int n;
  static bool d[2000][2000];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    char buf[2048];
    scanf("%s", buf);
    for (int j = 0; j < n; ++j) d[i][j] = buf[j] == '1';
  }
  int res = 0;
  static bool row1[2000], col1[2000], row2[2000], col2[2000];
  for (int y = n - 1; y > 0; --y)
    for (int x = 0; x < y; ++x)
      if (d[y][x] ^ row1[y] ^ col1[x]) ++res, row1[y] ^= true, col1[x] ^= true;
  for (int y = 0; y < n - 1; ++y)
    for (int x = n - 1; x > y; --x)
      if (d[y][x] ^ row2[y] ^ col2[x]) ++res, row2[y] ^= true, col2[x] ^= true;
  for (int i = 0; i < n; ++i)
    if (d[i][i] ^ row1[i] ^ row2[i] ^ col1[i] ^ col2[i]) ++res;
  printf("%d\n", res);
}
