import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Main main = new Main();

		main.solve();
	}

	private void solve () {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main{

	public static void main (String[] args) {

		Main main = new Main();

		main.solve();
	}

	private void solve () {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main (String[] args) {

		Main main = new Main();

		main.solve();
	} main {

		Main main = new Main();

		main.solve();
	} Main main = new Main(); main new Main() main.solve() main.solve main String[] args args private void solve () {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	} solve {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	} Scanner scanner = new Scanner (System.in); scanner new Scanner (System.in) int people = scanner.nextInt(); people scanner.nextInt() scanner.nextInt scanner int foodType = scanner.nextInt(); foodType scanner.nextInt() scanner.nextInt scanner int[] likeList = new int[foodType]; likeList new int[foodType] foodType for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		} int index=0; int index=0; index 0 index<people index people index++ index++ index {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		} {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		} int number = scanner.nextInt(); number scanner.nextInt() scanner.nextInt scanner for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			} int index2=0; int index2=0; index2 0 index2<number index2 number index2++ index2++ index2 {
				int food = scanner.nextInt();
				likeList[food-1]++;
			} {
				int food = scanner.nextInt();
				likeList[food-1]++;
			} int food = scanner.nextInt(); food scanner.nextInt() scanner.nextInt scanner likeList[food-1]++ likeList[food-1] likeList food-1 food 1 int count=0; count 0 for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		} int index=0; int index=0; index 0 index<foodType index foodType index++ index++ index {
			if (likeList[index]==people) {
				count++;
			}
		} {
			if (likeList[index]==people) {
				count++;
			}
		} if (likeList[index]==people) {
				count++;
			} likeList[index]==people likeList[index] likeList index people {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count public class Main{

	public static void main (String[] args) {

		Main main = new Main();

		main.solve();
	}

	private void solve () {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	}
} public class Main{

	public static void main (String[] args) {

		Main main = new Main();

		main.solve();
	}

	private void solve () {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Main main = new Main();

		main.solve();
	}

	private void solve () {

		Scanner scanner = new Scanner (System.in);

		int people = scanner.nextInt();
		int foodType = scanner.nextInt();
		int[] likeList = new int[foodType];

		for (int index=0; index<people; index++) {
			int number = scanner.nextInt();
			for (int index2=0; index2<number; index2++) {
				int food = scanner.nextInt();
				likeList[food-1]++;
			}
		}

		int count=0;

		for (int index=0; index<foodType; index++) {
			if (likeList[index]==people) {
				count++;
			}
		}
		System.out.println(count);
	}
}
