#include <bits/stdc++.h>
char s[2010][2010];
int hh[2010], ll[2010];
char change(char x) {
  if (x == '0') return '1';
  return '0';
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    int cnt = 0;
    memset(hh, 0, sizeof(hh));
    memset(ll, 0, sizeof(ll));
    for (int i = n - 1; i >= 1; i--)
      for (int j = 0; j <= i - 1; j++) {
        int num = hh[i] + ll[j];
        if (num % 2 == 1) s[i][j] = change(s[i][j]);
        if (s[i][j] == '1') {
          cnt++;
          hh[i]++;
          ll[j]++;
        }
      }
    for (int i = n - 1; i >= 0; i--) {
      int num = hh[i] + ll[i];
      if (num % 2 == 1) s[i][i] = change(s[i][i]);
    }
    memset(hh, 0, sizeof(hh));
    memset(ll, 0, sizeof(ll));
    for (int i = 0; i < n - 1; i++)
      for (int j = n - 1; j > i; j--) {
        int num = hh[i] + ll[j];
        if (num % 2 == 1) s[i][j] = change(s[i][j]);
        if (s[i][j] == '1') {
          hh[i]++;
          ll[j]++;
          cnt++;
        }
      }
    for (int i = n - 1; i >= 0; i--) {
      int num = hh[i] + ll[i];
      if (num % 2 == 1) s[i][i] = change(s[i][i]);
      if (s[i][i] == '1') cnt++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
