def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans)
main() def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M K = [] K [] for i in range(N):
        K.append(list(map(int, input().split())))
     i range(N) range N K.append(list(map(int, input().split()))) K.append K append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split l = [] l [] ans = 0 ans 0 for i in range(M+1):
        l.append(0)
     i range(M+1) range M+1 M 1 l.append(0) l.append l append 0 for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
     i range(N) range N for j in range(K[i][0]):
            l[K[i][j+1]] += 1
     j range(K[i][0]) range K[i][0] [i] K i 0 l[K[i][j+1]] += 1 l[K[i][j+1]] l K[i][j+1] [i] K i j+1 j 1 1 for i in range(len(l)):
        if l[i] == N:
            ans += 1
     i range(len(l)) range len(l) len l if l[i] == N:
            ans += 1
     l[i] == N l[i] l i N ans += 1 ans 1 print(ans) print ans main() main def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans) def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans) main
def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans)
main()