Matching Numbers in a Grid

We define an $M\times N$ grid such that all $M$ rows are numbered in increasing order, as well as all $N$ columns. Both numberings run from $1$ through $MN$. Here is an example $3\times 4$ grid:

\begingroup

\newcommand{\gridcell}[2] \makebox[15mm][c]$(#1,\,#2)$

\gridcell{1}{1} | \gridcell{2}{4} | \gridcell{3}{7} | \gridcell{4}{10} 

\gridcell{5}{2} | \gridcell{6}{5} | \gridcell{7}{8} | \gridcell{8}{11} 

\gridcell{9}{3} | \gridcell{10}{6} | \gridcell{11}{9} | \gridcell{12}{12} 

\endgroup

For a $141\times 91$ grid, how many squares get two copies of the same number?

Solutions