import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    ans = [0]*(M+1)
    for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
    print(ans.count(N))


if __name__ == '__main__':
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N, M = map(int, input().split())
    ans = [0]*(M+1)
    for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
    print(ans.count(N)) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ans = [0]*(M+1) ans [0]*(M+1) [0] 0 M+1 M 1 for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
     _ range(N) range N food = list(map(int, input().split())) food list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K = food[0] K food[0] food 0 for i in range(1, K + 1):
            ans[food[i]] += 1
     i range(1, K + 1) range 1 K + 1 K 1 ans[food[i]] += 1 ans[food[i]] ans food[i] food i 1 print(ans.count(N)) print ans.count(N) ans.count ans count N if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, M = map(int, input().split())
    ans = [0]*(M+1)
    for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
    print(ans.count(N)) def main():
    N, M = map(int, input().split())
    ans = [0]*(M+1)
    for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
    print(ans.count(N)) main input = sys.stdin.readline sys.stdin.readline input
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    ans = [0]*(M+1)
    for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
    print(ans.count(N))


if __name__ == '__main__':
    main()
