import sys

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    cnt = set(range(1, M+1))
    for _ in range(N):
        K, *A = map(int, input().split())
        cnt.intersection_update(set(A))
    ans = len(cnt)
    print(ans)

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())
    cnt = set(range(1, M+1))
    for _ in range(N):
        K, *A = map(int, input().split())
        cnt.intersection_update(set(A))
    ans = len(cnt)
    print(ans) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M cnt = set(range(1, M+1)) cnt set(range(1, M+1)) set range(1, M+1) range 1 M+1 M 1 for _ in range(N):
        K, *A = map(int, input().split())
        cnt.intersection_update(set(A))
     _ range(N) range N K, *A = map(int, input().split()) K map(int, input().split()) map int input().split() ().split () input split *A A cnt.intersection_update(set(A)) cnt.intersection_update cnt intersection_update set(A) set A ans = len(cnt) ans len(cnt) len cnt print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, M = map(int, input().split())
    cnt = set(range(1, M+1))
    for _ in range(N):
        K, *A = map(int, input().split())
        cnt.intersection_update(set(A))
    ans = len(cnt)
    print(ans) def main():
    N, M = map(int, input().split())
    cnt = set(range(1, M+1))
    for _ in range(N):
        K, *A = map(int, input().split())
        cnt.intersection_update(set(A))
    ans = len(cnt)
    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    cnt = set(range(1, M+1))
    for _ in range(N):
        K, *A = map(int, input().split())
        cnt.intersection_update(set(A))
    ans = len(cnt)
    print(ans)

if __name__ == "__main__":
    main()
