#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
double a[35][35];
inline int solve(int n)
{
    int res = 0, r = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = r; j < n; j++)
        {
            if (abs(a[j][i]) > eps)
            {
                for (int k = i; k <= n; ++k)
                    swap(a[j][k], a[r][k]);
                break;
            }
        }
        if (abs(a[r][i]) < eps)
        {
            res++;
            continue;
        }
        for (int j = 0; j < n; j++)
            if (j != r && abs(a[j][i]) > eps)
            {
                double tmp = a[j][i] / a[r][i];
                for (int k = i; k <= n; k++)
                    a[j][k] -= tmp * a[r][k];
            }
        r++;
    }
    return res;
}
int main()
{
    int r, c, x;
    while (~scanf("%d%d", &r, &c))
    {
        for (int i = 0; i < r; i++)
            for (int j = 0; j < c; j++)
                scanf("%lf", &a[i][j]);
        printf("%d\n", min(r * c, (r - solve(r)) * c + c));
    }
    return 0;
}
