import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
ka = [li() for _ in range(n)]

food = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1
print(food.count(n)) import math math import collections collections from sys import exit from itertools import product ii = lambda : int(input()) ii lambda : int(input()) int(input()) int input() input mi = lambda : map(int,input().split()) mi lambda : map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split li = lambda : list(map(int,input().split())) li lambda : list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split n,m = mi() n mi() mi m li() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) li() li ka = [li() for _ in range(n)] ka [li() for _ in range(n)] food = [0]*m food [0]*m [0] 0 m for i in range(n):
    for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1 i range(n) range n for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1 j range(1,ka[i][0]+1,1) range 1 ka[i][0]+1 ka[i][0] [i] ka i 0 1 1 food[ka[i][j]-1] += 1 food[ka[i][j]-1] food ka[i][j]-1 ka[i][j] [i] ka i j 1 1 print(food.count(n)) print food.count(n) food.count food count n n,m = mi() mi() n ka = [li() for _ in range(n)] [li() for _ in range(n)] ka mi = lambda : map(int,input().split()) lambda : map(int,input().split()) mi food = [0]*m [0]*m food m = mi() mi() m ii = lambda : int(input()) lambda : int(input()) ii li = lambda : list(map(int,input().split())) lambda : list(map(int,input().split())) li
import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
ka = [li() for _ in range(n)]

food = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1
print(food.count(n))