import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int kinds = sc.nextInt(); kinds sc.nextInt() sc.nextInt sc int like[] = new int[kinds]; like new int[kinds] kinds for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		} int i = 0; int i = 0; i 0 i < kinds i kinds i ++ i ++ i {
			like[i] = 0;
		} {
			like[i] = 0;
		} like[i] = 0 like[i] like i 0 for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		} int i = 0; int i = 0; i 0 i < num i num i ++ i ++ i {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		} {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		} int likeNum = sc.nextInt(); likeNum sc.nextInt() sc.nextInt sc for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			} int j = 0; int j = 0; j 0 j < likeNum j likeNum j ++ j ++ j {
				like[sc.nextInt() - 1] ++;
			} {
				like[sc.nextInt() - 1] ++;
			} like[sc.nextInt() - 1] ++ like[sc.nextInt() - 1] like sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int count = 0; count 0 for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		} int i = 0; int i = 0; i 0 i < kinds i kinds i ++ i ++ i {
			if(like[i] == num) {
				count ++;
			}
		} {
			if(like[i] == num) {
				count ++;
			}
		} if(like[i] == num) {
				count ++;
			} like[i] == num like[i] like i num {
				count ++;
			} count ++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	}
}