You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer k > 1 and split the image into k by k blocks. If n and m are not divisible by k, the image is padded with only zeros on the right and bottom so that they are divisible by k. Each pixel in each individual block must have the same value. The given image may not be compressible in its current state. Find the minimum number of pixels you need to toggle (after padding) in order for the image to be compressible for some k. More specifically, the steps are to first choose k, then the image is padded with zeros, then, we can toggle the pixels so it is compressible for this k. The image must be compressible in that state.


-----Input-----

The first line of input will contain two integers n, m (2 ≤ n, m ≤ 2 500), the dimensions of the image.

The next n lines of input will contain a binary string with exactly m characters, representing the image.


-----Output-----

Print a single integer, the minimum number of pixels needed to toggle to make the image compressible.


-----Example-----
Input
3 5
00100
10110
11001

Output
5



-----Note-----

We first choose k = 2.

The image is padded as follows: 

001000

101100

110010

000000



We can toggle the image to look as follows: 

001100

001100

000000

000000



We can see that this image is compressible for k = 2.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "#!/usr/bin/env python\n# coding:utf-8\n# Copyright (C) dirlt\n\nfrom sys import stdin\n\n\ndef run(n, m, pixels):\n    ans = 1 << 30\n\n    acc = [[0] * (m + 1) for _ in range(n + 1)]\n    for i in range(n):\n        for j in range(m):\n            acc[i + 1][j + 1] = acc[i + 1][j] + int(pixels[i][j])\n        for j in range(m):\n            acc[i + 1][j + 1] += acc[i][j + 1]\n    # print(acc)\n\n    for k in range(2, max(n, m) + 1):\n        r, c = (n + k - 1) // k, (m + k - 1) // k\n        res = 0\n        for i in range(r):\n            for j in range(c):\n                x, y = i * k, j * k\n                x2, y2 = min(x + k - 1, n - 1), min(y + k - 1, m - 1)\n                zero = acc[x2 + 1][y2 + 1] - acc[x][y2 + 1] - acc[x2 + 1][y] + acc[x][y]\n                # print(x, y, k, zero, k * k - zero)\n                res += min(zero, k * k - zero)\n        # print(k, res)\n        ans = min(ans, res)\n    print(ans)\n\n\ndef main():\n    n, m = [int(x) for x in stdin.readline().split()]\n    pixels = []\n    for i in range(n):\n        pixels.append(stdin.readline().strip())\n    run(n, m, pixels)\n\n\ndef __starting_point():\n    import os\n\n    if os.path.exists('tmp.in'):\n        stdin = open('tmp.in')\n    main()\n\n__starting_point()"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14439