#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T checkmin(T &a, T b) {
  return (a < b) ? a : a = b;
}
template <class T>
inline T checkmax(T &a, T b) {
  return (a > b) ? a : a = b;
}
template <class T>
T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (a == 0) ? b : GCD(b % a, a);
}
template <class T>
T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return (a == 0 || b == 0) ? 0 : a / GCD(a, b) * b;
}
template <class T>
T ExtGCD(T a, T b, T &x, T &y) {
  if (a < 0) {
    T c = ExtGCD(-a, b, x, y);
    x = -x;
    return c;
  }
  if (b < 0) {
    T c = ExtGCD(a, -b, x, y);
    y = -y;
    return c;
  }
  if (a == 0) {
    x = 0, y = 1;
    return b;
  } else {
    T c = ExtGCD(b % a, a, y, x);
    x -= b / a * y;
    return c;
  }
}
template <class T>
inline T sqr(T X) {
  return X * X;
}
namespace Poor {
const int MaxiN = 2005;
int N;
int Map[MaxiN][MaxiN];
int Line[MaxiN], Row[MaxiN];
void Run() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j) {
      char Ch = getchar();
      while (!isdigit(Ch)) Ch = getchar();
      Map[i][j] = Ch - '0';
    }
  int res = 0;
  fill(Line, Line + N, 0);
  fill(Row, Row + N, 0);
  for (int i = 0; i < N; ++i) {
    for (int j = N - 1; j > i; --j)
      if (Map[i][j] ^ Line[i] ^ Row[j]) {
        ++res;
        Line[i] ^= 1;
        Row[j] ^= 1;
      }
    Map[i][i] ^= Line[i] ^ Row[i];
  }
  fill(Line, Line + N, 0);
  fill(Row, Row + N, 0);
  for (int i = N - 1; i >= 0; --i) {
    for (int j = 0; j < i; ++j)
      if (Map[i][j] ^ Line[i] ^ Row[j]) {
        ++res;
        Line[i] ^= 1;
        Row[j] ^= 1;
      }
    Map[i][i] ^= Line[i] ^ Row[i];
  }
  for (int i = 0; i < N; ++i)
    if (Map[i][i]) ++res;
  printf("%d\n", res);
}
}  // namespace Poor
int main() { Poor::Run(); }
