# coding: utf-8

# https://atcoder.jp/contests/abc118


def main():
    N, M = map(int, input().split())
    k_a = [None] * N
    for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
    food = [0] * (M+1)
    for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
    ans = 0
    for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
    return ans


print(main()) def main():
    N, M = map(int, input().split())
    k_a = [None] * N
    for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
    food = [0] * (M+1)
    for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
    ans = 0
    for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
    return ans main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M k_a = [None] * N k_a [None] * N [None] None N for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
     i range(N) range N k_a[i] = list(map(int, input().split())) k_a[i] k_a i list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split food = [0] * (M+1) food [0] * (M+1) [0] 0 M+1 M 1 for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
     i range(N) range N for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
     j range(1, k_a[i][0]+1) range 1 k_a[i][0]+1 k_a[i][0] [i] k_a i 0 1 food[k_a[i][j]] += 1 food[k_a[i][j]] food k_a[i][j] [i] k_a i j 1 ans = 0 ans 0 for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
     m range(1, M+1) range 1 M+1 M 1 if food[m] == N:
            ans += 1
    
     food[m] == N food[m] food m N ans += 1 ans 1 return ans ans print(main()) print main() main def main():
    N, M = map(int, input().split())
    k_a = [None] * N
    for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
    food = [0] * (M+1)
    for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
    ans = 0
    for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
    return ans def main():
    N, M = map(int, input().split())
    k_a = [None] * N
    for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
    food = [0] * (M+1)
    for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
    ans = 0
    for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
    return ans main
# coding: utf-8

# https://atcoder.jp/contests/abc118


def main():
    N, M = map(int, input().split())
    k_a = [None] * N
    for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
    food = [0] * (M+1)
    for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
    ans = 0
    for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
    return ans


print(main())
