/*
TASK: matrix
LANG: C++
*/
#include <iostream>
using namespace std;
int data[1001][1001];
int x = 0;
int y = 0;
int solve();
bool compare(int p1, int p2);
int main()
{
cin >> x >> y;
for (int i=0; i<= x-1; i++)
for (int j=0; j<= y-1; j++)
cin >> data[i][j];
cout << solve() << endl;
return 0;
}
int solve()
{
bool iss = true;
int res = 0;
for (int i = 0; i<=x-1;i++)
{
iss = true;
for (int j = i+1; j <=x-1; j++)
{
if(compare(i, j))
{
iss = false;
}
}
if (iss) res++;
}
return res;
}
bool compare(int p1, int p2)
{
int ret = 0;
bool th[y];
bool th0[y];
for(int a = 0; a <= y; a++)
{
th[a] = false;
th0[a] = false;
}
for (int i = 0; i<=y-1; i++)
{
for(int j = 0; j <= y-1; j++)
{
if((data[p1][i] == data[p2][j]) && !th[j] && !th0[i])
{
th[j] = true;
th0[i] = true;
ret++;
j = y;
}
}
}
if(ret == y) return true;
else return false;
}
