#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
d={i:0 for i in range(1,m+1)}
for i in range(n):
    a=list(map(int,input().split()))
    k=a[0]
    for j in range(k):
        d[a[j+1]]+=1
ans=0
for i in d.keys():
    if d[i]==n:
        ans+=1
print(ans) from collections import deque n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m i:0 for i in range(1,m+1) for i in range(1,m+1) i range(1,m+1) range 1 m+1 m 1 for i in range(1,m+1) i 0 d={i:0 for i in range(1,m+1)} d {i:0 for i in range(1,m+1)} for i in range(n):
    a=list(map(int,input().split()))
    k=a[0]
    for j in range(k):
        d[a[j+1]]+=1 i range(n) range n a=list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k=a[0] k a[0] a 0 for j in range(k):
        d[a[j+1]]+=1 j range(k) range k d[a[j+1]]+=1 d[a[j+1]] d a[j+1] a j+1 j 1 1 ans=0 ans 0 for i in d.keys():
    if d[i]==n:
        ans+=1 i d.keys() d.keys d keys if d[i]==n:
        ans+=1 d[i]==n d[i] d i n ans+=1 ans 1 print(ans) print ans n,m=map(int,input().split()) map(int,input().split()) n d={i:0 for i in range(1,m+1)} {i:0 for i in range(1,m+1)} d k=a[0] a[0] k a=list(map(int,input().split())) list(map(int,input().split())) a ans=0 0 ans m=map(int,input().split()) map(int,input().split()) m ans+=1 1 ans
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
d={i:0 for i in range(1,m+1)}
for i in range(n):
    a=list(map(int,input().split()))
    k=a[0]
    for j in range(k):
        d[a[j+1]]+=1
ans=0
for i in d.keys():
    if d[i]==n:
        ans+=1
print(ans)