import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    cnt = [0] * (M + 1)

    for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

    print(cnt.count(N))


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    N, M = map(int, readline().split())
    cnt = [0] * (M + 1)

    for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

    print(cnt.count(N)) main N, M = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split M cnt = [0] * (M + 1) cnt [0] * (M + 1) [0] 0 M + 1 M 1 for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

     _ range(N) range N K, *A = list(map(int, readline().split())) K list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split *A A for x in A:
            cnt[x] += 1

     x A cnt[x] += 1 cnt[x] cnt x 1 print(cnt.count(N)) print cnt.count(N) cnt.count cnt count N if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, M = map(int, readline().split())
    cnt = [0] * (M + 1)

    for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

    print(cnt.count(N)) def main():
    N, M = map(int, readline().split())
    cnt = [0] * (M + 1)

    for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

    print(cnt.count(N)) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = float('INF') float('INF') INF readline = sys.stdin.readline sys.stdin.readline readline
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    cnt = [0] * (M + 1)

    for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

    print(cnt.count(N))


if __name__ == '__main__':
    main()
