Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years.
×

Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

C. E-reader Display

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputAfter years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual management. For that very reason the developers decided to leave the e-readers' software to programmers.

The display is represented by *n* × *n* square of pixels, each of which can be either black or white. The display rows are numbered with integers from 1 to *n* upside down, the columns are numbered with integers from 1 to *n* from the left to the right. The display can perform commands like "*x*, *y*". When a traditional display fulfills such command, it simply inverts a color of (*x*, *y*), where *x* is the row number and *y* is the column number. But in our new display every pixel that belongs to at least one of the segments (*x*, *x*) - (*x*, *y*) and (*y*, *y*) - (*x*, *y*) (both ends of both segments are included) inverts a color.

For example, if initially a display 5 × 5 in size is absolutely white, then the sequence of commands (1, 4), (3, 5), (5, 1), (3, 3) leads to the following changes:

You are an e-reader software programmer and you should calculate minimal number of commands needed to display the picture. You can regard all display pixels as initially white.

Input

The first line contains number *n* (1 ≤ *n* ≤ 2000).

Next *n* lines contain *n* characters each: the description of the picture that needs to be shown. "0" represents the white color and "1" represents the black color.

Output

Print one integer *z* — the least number of commands needed to display the picture.

Examples

Input

5

01110

10010

10001

10011

11110

Output

4

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/29/2020 07:48:30 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|