import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, input().split())
suki = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        suki[a-1] += 1

ans = len(list(filter(lambda x: x == N, suki)))
print(ans) import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 INF = float('inf') INF float('inf') float 'inf' N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M suki = [0] * M suki [0] * M [0] 0 M for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        suki[a-1] += 1 _ range(N) range N K, *A = map(int, input().split()) K map(int, input().split()) map int input().split() ().split () input split *A A for a in A:
        suki[a-1] += 1 a A suki[a-1] += 1 suki[a-1] suki a-1 a 1 1 ans = len(list(filter(lambda x: x == N, suki))) ans len(list(filter(lambda x: x == N, suki))) len list(filter(lambda x: x == N, suki)) list filter(lambda x: x == N, suki) filter lambda x: x == N x == N x N x suki print(ans) print ans ans = len(list(filter(lambda x: x == N, suki))) len(list(filter(lambda x: x == N, suki))) ans read = sys.stdin.buffer.read sys.stdin.buffer.read read M = map(int, input().split()) map(int, input().split()) M readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline N, M = map(int, input().split()) map(int, input().split()) N K, *A = map(int, input().split()) map(int, input().split()) K suki = [0] * M [0] * M suki INF = float('inf') float('inf') INF readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, input().split())
suki = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        suki[a-1] += 1

ans = len(list(filter(lambda x: x == N, suki)))
print(ans)
