import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[i] == n:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[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 foods = [0] * m foods [0] * m [0] 0 m ans = 0 ans 0 for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
     _ range(n) range n k = list(map(int, input().split())) k list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
     i range(1, k[0]+1) range 1 k[0]+1 k[0] k 0 1 foods[k[i]-1] += 1 foods[k[i]-1] foods k[i]-1 k[i] k i 1 1 for i in range(m):
        if foods[i] == n:
            ans += 1
     i range(m) range m if foods[i] == n:
            ans += 1
     foods[i] == n foods[i] foods i n ans += 1 ans 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[i] == n:
            ans += 1
    print(ans)
         def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[i] == n:
            ans += 1
    print(ans)
         main input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[i] == n:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()