#include <bits/stdc++.h>
char s[2010][2010];
bool s1[2010][2010], s2[2010][2010], s3[2010][2010], s4[2010][2010];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int ans = 0;
    for (int i = 0; i < n; ++i) scanf("%s", s[i]);
    for (int i = 0; i < n; ++i)
      for (int j = n - 1; j > i; --j) {
        bool u = j + 1 == n ? 0 : s1[i][j + 1], v = i ? s2[i - 1][j] : 0,
             t = s[i][j] == '1', p = u ^ v ^ t;
        ans += p;
        s1[i][j] = u ^ p, s2[i][j] = v ^ p;
      }
    for (int i = n - 1; i > 0; --i)
      for (int j = 0; j < i; ++j) {
        int u = j ? s3[i][j - 1] : 0, v = i + 1 == n ? 0 : s4[i + 1][j],
            t = s[i][j] == '1', p = u ^ v ^ t;
        ans += p;
        s3[i][j] = u ^ p, s4[i][j] = v ^ p;
      }
    for (int i = 0; i < n; ++i) {
      bool a = i + 1 == n ? 0 : s1[i][i + 1], b = i ? s2[i - 1][i] : 0,
           c = i ? s3[i][i - 1] : 0, d = i + 1 == n ? 0 : s4[i + 1][i],
           t = s[i][i] == '1';
      ans += a ^ b ^ c ^ d ^ t;
    }
    printf("%d\n", ans);
  }
  return 0;
}
