#!/usr/bin/env python3

def main():
    n, m = map(int, input().split())
    k, *a = map(int, input().split())
    ans = set(a)
    for i in range(n - 1):
        k, *a = map(int, input().split())
        ans = ans & set(a)
    print(len(ans))


if __name__ == "__main__":
    main() def main():
    n, m = map(int, input().split())
    k, *a = map(int, input().split())
    ans = set(a)
    for i in range(n - 1):
        k, *a = map(int, input().split())
        ans = ans & set(a)
    print(len(ans)) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m k, *a = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *a a ans = set(a) ans set(a) set a for i in range(n - 1):
        k, *a = map(int, input().split())
        ans = ans & set(a)
     i range(n - 1) range n - 1 n 1 k, *a = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *a a ans = ans & set(a) ans ans & set(a) ans set(a) set a print(len(ans)) print len(ans) len ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n, m = map(int, input().split())
    k, *a = map(int, input().split())
    ans = set(a)
    for i in range(n - 1):
        k, *a = map(int, input().split())
        ans = ans & set(a)
    print(len(ans)) def main():
    n, m = map(int, input().split())
    k, *a = map(int, input().split())
    ans = set(a)
    for i in range(n - 1):
        k, *a = map(int, input().split())
        ans = ans & set(a)
    print(len(ans)) main
#!/usr/bin/env python3

def main():
    n, m = map(int, input().split())
    k, *a = map(int, input().split())
    ans = set(a)
    for i in range(n - 1):
        k, *a = map(int, input().split())
        ans = ans & set(a)
    print(len(ans))


if __name__ == "__main__":
    main()
