import java.io.InputStream;
import java.io.PrintStream;
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		BitSet a = new BitSet(M);
		a.flip(0, M);

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		}

		out.println(a.cardinality());

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.BitSet; BitSet java.util import java.util.Scanner; Scanner java.util public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		BitSet a = new BitSet(M);
		a.flip(0, M);

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		}

		out.println(a.cardinality());

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} Main InputStream in = System.in; in System.in System System.in PrintStream out = System.out; out System.out System System.out public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		BitSet a = new BitSet(M);
		a.flip(0, M);

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		}

		out.println(a.cardinality());

		sc.close();

	} _main {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		BitSet a = new BitSet(M);
		a.flip(0, M);

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		}

		out.println(a.cardinality());

		sc.close();

	} Scanner sc = new Scanner(in); sc new Scanner(in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc BitSet a = new BitSet(M); a new BitSet(M) a.flip(0, M) a.flip a 0 M for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		} {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc BitSet x = new BitSet(M); x new BitSet(M) for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			} {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			} x.set(sc.nextInt() - 1) x.set x sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 a.and(x) a.and a x out.println(a.cardinality()) out.println out a.cardinality() a.cardinality a sc.close() sc.close sc String[] args args public static void main(String[] args) {
		new Main()._main(args);
	} main {
		new Main()._main(args);
	} new Main()._main(args) new Main()._main new Main() args String[] args args public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		BitSet a = new BitSet(M);
		a.flip(0, M);

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		}

		out.println(a.cardinality());

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		BitSet a = new BitSet(M);
		a.flip(0, M);

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		}

		out.println(a.cardinality());

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} Main
import java.io.InputStream;
import java.io.PrintStream;
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		BitSet a = new BitSet(M);
		a.flip(0, M);

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			BitSet x = new BitSet(M);
			for (int j = 0; j < K; j++) {
				x.set(sc.nextInt() - 1); // 入力は1オリジンなので1引く
			}
			a.and(x);
		}

		out.println(a.cardinality());

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}
