#include <bits/stdc++.h>
char mp[2100][2100], tmp[2100][2100];
int go[2100];
int main() {
  int i, j, k, l, m, n, loop;
  int res;
  while (scanf("%d", &n) == 1) {
    for (i = 0; i < n; i++) scanf("%s", mp[i]);
    res = 0;
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) mp[i][j] -= '0';
    for (loop = 0; loop < 2; loop++) {
      for (i = 0; i < n; i++) go[i] = 0;
      for (i = n - 1; i >= 0; i--) {
        k = 0;
        for (j = 0; j <= i; j++) {
          m = mp[i][j];
          m += k;
          m += go[j];
          if (j != i) {
            if (m % 2) {
              res++;
              k++;
              go[j]++;
            }
            mp[i][j] = 0;
          } else {
            mp[i][j] = m % 2;
          }
        }
      }
      if (loop == 0) {
        for (i = 0; i < n; i++)
          for (j = 0; j < n; j++) tmp[i][j] = mp[i][j];
        for (i = 0; i < n; i++)
          for (j = 0; j < n; j++) mp[i][j] = tmp[j][i];
      }
    }
    for (i = 0; i < n; i++)
      if (mp[i][i]) res++;
    printf("%d\n", res);
  }
  return 0;
}
