import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int nPerson = sc.nextInt();
		int mKind = sc.nextInt();
		boolean[] isAllLike = new boolean[mKind];
		for (int i = 0; i < mKind; i++) {
			isAllLike[i] = true;
		}

		for (int i = 0; i < nPerson; i++) {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		}
		
		int res = 0;
		for(int i=0;i<isAllLike.length;i++) {
			if(isAllLike[i]) {
				res++;
			}
		}

		System.out.println(res);
	}
} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int nPerson = sc.nextInt();
		int mKind = sc.nextInt();
		boolean[] isAllLike = new boolean[mKind];
		for (int i = 0; i < mKind; i++) {
			isAllLike[i] = true;
		}

		for (int i = 0; i < nPerson; i++) {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		}
		
		int res = 0;
		for(int i=0;i<isAllLike.length;i++) {
			if(isAllLike[i]) {
				res++;
			}
		}

		System.out.println(res);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int nPerson = sc.nextInt();
		int mKind = sc.nextInt();
		boolean[] isAllLike = new boolean[mKind];
		for (int i = 0; i < mKind; i++) {
			isAllLike[i] = true;
		}

		for (int i = 0; i < nPerson; i++) {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		}
		
		int res = 0;
		for(int i=0;i<isAllLike.length;i++) {
			if(isAllLike[i]) {
				res++;
			}
		}

		System.out.println(res);
	} main {
		Scanner sc = new Scanner(System.in);
		int nPerson = sc.nextInt();
		int mKind = sc.nextInt();
		boolean[] isAllLike = new boolean[mKind];
		for (int i = 0; i < mKind; i++) {
			isAllLike[i] = true;
		}

		for (int i = 0; i < nPerson; i++) {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		}
		
		int res = 0;
		for(int i=0;i<isAllLike.length;i++) {
			if(isAllLike[i]) {
				res++;
			}
		}

		System.out.println(res);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int nPerson = sc.nextInt(); nPerson sc.nextInt() sc.nextInt sc int mKind = sc.nextInt(); mKind sc.nextInt() sc.nextInt sc boolean[] isAllLike = new boolean[mKind]; isAllLike new boolean[mKind] mKind for (int i = 0; i < mKind; i++) {
			isAllLike[i] = true;
		} int i = 0; int i = 0; i 0 i < mKind i mKind i++ i++ i {
			isAllLike[i] = true;
		} {
			isAllLike[i] = true;
		} isAllLike[i] = true isAllLike[i] isAllLike i true for (int i = 0; i < nPerson; i++) {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		} int i = 0; int i = 0; i 0 i < nPerson i nPerson i++ i++ i {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		} {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		} int kLikeFood = sc.nextInt(); kLikeFood sc.nextInt() sc.nextInt sc boolean[] nPersonLike = new boolean[mKind]; nPersonLike new boolean[mKind] mKind for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			} int j = 0; int j = 0; j 0 j < kLikeFood j kLikeFood j++ j++ j {
				nPersonLike[sc.nextInt() - 1] = true;
			} {
				nPersonLike[sc.nextInt() - 1] = true;
			} nPersonLike[sc.nextInt() - 1] = true nPersonLike[sc.nextInt() - 1] nPersonLike sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 true for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			} int j = 0; int j = 0; j 0 j < mKind j mKind j++ j++ j {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			} {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			} if (!nPersonLike[j]) {
					isAllLike[j] = false;
				} !nPersonLike[j] nPersonLike[j] nPersonLike j {
					isAllLike[j] = false;
				} isAllLike[j] = false isAllLike[j] isAllLike j false int res = 0; res 0 for(int i=0;i<isAllLike.length;i++) {
			if(isAllLike[i]) {
				res++;
			}
		} int i=0; int i=0; i 0 i<isAllLike.length i isAllLike.length isAllLike isAllLike.length i++ i++ i {
			if(isAllLike[i]) {
				res++;
			}
		} {
			if(isAllLike[i]) {
				res++;
			}
		} if(isAllLike[i]) {
				res++;
			} isAllLike[i] isAllLike i {
				res++;
			} res++ res System.out.println(res) System.out.println System.out System System.out res String[] args args
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int nPerson = sc.nextInt();
		int mKind = sc.nextInt();
		boolean[] isAllLike = new boolean[mKind];
		for (int i = 0; i < mKind; i++) {
			isAllLike[i] = true;
		}

		for (int i = 0; i < nPerson; i++) {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		}
		
		int res = 0;
		for(int i=0;i<isAllLike.length;i++) {
			if(isAllLike[i]) {
				res++;
			}
		}

		System.out.println(res);
	}
}
