import sys
import collections
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, m = [int(num) for num in lines.pop(0).split(" ")]
def iter_a_set():
    for line in lines:
        fs = [int(num) for num in line.split(" ")]
        k = fs.pop(0)
        yield set(fs)
foods = set(range(1, m + 1))
for a_set in iter_a_set():
    foods &= a_set
print(len(foods)) import sys sys import collections collections s.rstrip("\n") for s in sys.stdin.readlines() for s in sys.stdin.readlines() s sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for s in sys.stdin.readlines() s.rstrip("\n") s.rstrip s rstrip "\n" lines = [s.rstrip("\n") for s in sys.stdin.readlines()] lines [s.rstrip("\n") for s in sys.stdin.readlines()] int(num) for num in lines.pop(0).split(" ") for num in lines.pop(0).split(" ") num lines.pop(0).split(" ") lines.pop(0).split lines.pop(0) lines.pop lines pop 0 split " " for num in lines.pop(0).split(" ") int(num) int num n, m = [int(num) for num in lines.pop(0).split(" ")] n [int(num) for num in lines.pop(0).split(" ")] m def iter_a_set():
    for line in lines:
        fs = [int(num) for num in line.split(" ")]
        k = fs.pop(0)
        yield set(fs) iter_a_set for line in lines:
        fs = [int(num) for num in line.split(" ")]
        k = fs.pop(0)
        yield set(fs) line lines int(num) for num in line.split(" ") for num in line.split(" ") num line.split(" ") line.split line split " " for num in line.split(" ") int(num) int num fs = [int(num) for num in line.split(" ")] fs [int(num) for num in line.split(" ")] k = fs.pop(0) k fs.pop(0) fs.pop fs pop 0 yield set(fs) set(fs) set fs foods = set(range(1, m + 1)) foods set(range(1, m + 1)) set range(1, m + 1) range 1 m + 1 m 1 for a_set in iter_a_set():
    foods &= a_set a_set iter_a_set() iter_a_set foods &= a_set foods a_set print(len(foods)) print len(foods) len foods foods &= a_set a_set foods lines = [s.rstrip("\n") for s in sys.stdin.readlines()] [s.rstrip("\n") for s in sys.stdin.readlines()] lines m = [int(num) for num in lines.pop(0).split(" ")] [int(num) for num in lines.pop(0).split(" ")] m foods = set(range(1, m + 1)) set(range(1, m + 1)) foods n, m = [int(num) for num in lines.pop(0).split(" ")] [int(num) for num in lines.pop(0).split(" ")] n def iter_a_set():
    for line in lines:
        fs = [int(num) for num in line.split(" ")]
        k = fs.pop(0)
        yield set(fs) def iter_a_set():
    for line in lines:
        fs = [int(num) for num in line.split(" ")]
        k = fs.pop(0)
        yield set(fs) iter_a_set
import sys
import collections
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, m = [int(num) for num in lines.pop(0).split(" ")]
def iter_a_set():
    for line in lines:
        fs = [int(num) for num in line.split(" ")]
        k = fs.pop(0)
        yield set(fs)
foods = set(range(1, m + 1))
for a_set in iter_a_set():
    foods &= a_set
print(len(foods))
