{
TASK:MATRIX
LANG:PASCAL
}
type
sett=array[1..10000] of integer;
var
a:Array[1..1000] of sett;
b:sett;
count,k,i,j,n,m:integer;
c:boolean;
function check(a,b:sett):boolean;
var i:integer;k:boolean;
begin
k:=true;
for i:=1 to 10000 do if a[i]<>b[i] then begin k:=false;break;end;
check:=k;
end;

begin
readln(n,m);
for i:=1 to n do
 begin
 for j:=1 to 10000 do b[j]:=0;
 for j:=1 to m do begin read(k);inc(b[k]);end;
 c:=true;
 for j:=1 to count do if check(b,a[j]) then c:=false;
 if c then begin
           inc(count);
           a[count]:=b;
           end;
 end;
writeln(count);


end.
