import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N = l[0]
M = l[1]
KA = [list(map(int,input().split())) for c in range(N)]

F = [0]*M

for i in range(N):
    for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1
print(F.count(N)) import sys sys import copy copy import math math import itertools itertools import numpy as np numpy int(c) for c in input().split() for c in input().split() c input().split() ().split () input split for c in input().split() int(c) int c l = [int(c) for c in input().split()] l [int(c) for c in input().split()] N = l[0] N l[0] l 0 M = l[1] M l[1] l 1 list(map(int,input().split())) for c in range(N) for c in range(N) c range(N) range N for c in range(N) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split KA = [list(map(int,input().split())) for c in range(N)] KA [list(map(int,input().split())) for c in range(N)] F = [0]*M F [0]*M [0] 0 M for i in range(N):
    for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1 i range(N) range N for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1 j range(1,KA[i][0]+1) range 1 KA[i][0]+1 KA[i][0] [i] KA i 0 1 F[KA[i][j]-1]+=1 F[KA[i][j]-1] F KA[i][j]-1 KA[i][j] [i] KA i j 1 1 print(F.count(N)) print F.count(N) F.count F count N l = [int(c) for c in input().split()] [int(c) for c in input().split()] l M = l[1] l[1] M KA = [list(map(int,input().split())) for c in range(N)] [list(map(int,input().split())) for c in range(N)] KA N = l[0] l[0] N F = [0]*M [0]*M F
import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N = l[0]
M = l[1]
KA = [list(map(int,input().split())) for c in range(N)]

F = [0]*M

for i in range(N):
    for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1
print(F.count(N))