import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	int M;

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
		A = new int[N][M];
	}

	public boolean hasNext() {
		return cnt < N;
	}

	int A[][];

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		int k = Integer.parseInt(strArr[0]);
		for (int i = 1; i <= k; i++) {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		}
		cnt++;
	}

	public void solve() {
		int ans = 0;
		for (int m = 0; m < M; m++) {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		}
		System.out.println(ans);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
} Main public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) Solver solver = new Solver(); solver new Solver() solver.init() solver.init solver solver.readHead(in.readLine()) solver.readHead solver in.readLine() in.readLine in for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		} ; solver.hasNext() solver.hasNext solver {
			solver.readBody(in.readLine());
		} {
			solver.readBody(in.readLine());
		} solver.readBody(in.readLine()) solver.readBody solver in.readLine() in.readLine in solver.solve() solver.solve solver String args[] args class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	int M;

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
		A = new int[N][M];
	}

	public boolean hasNext() {
		return cnt < N;
	}

	int A[][];

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		int k = Integer.parseInt(strArr[0]);
		for (int i = 1; i <= k; i++) {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		}
		cnt++;
	}

	public void solve() {
		int ans = 0;
		for (int m = 0; m < M; m++) {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		}
		System.out.println(ans);
	}
} Solver int N; N int cnt; cnt int M; M int A[][]; A public void init() {
		N = 0;
		cnt = 0;
	} init {
		N = 0;
		cnt = 0;
	} N = 0 N 0 cnt = 0 cnt 0 public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
		A = new int[N][M];
	} readHead {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
		A = new int[N][M];
	} String[] strArr = str.split(" "); strArr str.split(" ") str.split str " " N = Integer.parseInt(strArr[0]) N Integer.parseInt(strArr[0]) Integer.parseInt Integer strArr[0] strArr 0 M = Integer.parseInt(strArr[1]) M Integer.parseInt(strArr[1]) Integer.parseInt Integer strArr[1] strArr 1 A = new int[N][M] A new int[N][M] N M String str str public boolean hasNext() {
		return cnt < N;
	} hasNext {
		return cnt < N;
	} return cnt < N; cnt < N cnt N public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		int k = Integer.parseInt(strArr[0]);
		for (int i = 1; i <= k; i++) {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		}
		cnt++;
	} readBody {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		int k = Integer.parseInt(strArr[0]);
		for (int i = 1; i <= k; i++) {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		}
		cnt++;
	} String[] strArr = str.split(" "); strArr str.split(" ") str.split str " " int k = Integer.parseInt(strArr[0]); k Integer.parseInt(strArr[0]) Integer.parseInt Integer strArr[0] strArr 0 for (int i = 1; i <= k; i++) {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		} int i = 1; int i = 1; i 1 i <= k i k i++ i++ i {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		} {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		} A[cnt][Integer.parseInt(strArr[i]) - 1] = 1 A[cnt][Integer.parseInt(strArr[i]) - 1] A[cnt] A cnt Integer.parseInt(strArr[i]) - 1 Integer.parseInt(strArr[i]) Integer.parseInt Integer strArr[i] strArr i 1 1 cnt++ cnt String str str public void solve() {
		int ans = 0;
		for (int m = 0; m < M; m++) {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		}
		System.out.println(ans);
	} solve {
		int ans = 0;
		for (int m = 0; m < M; m++) {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		}
		System.out.println(ans);
	} int ans = 0; ans 0 for (int m = 0; m < M; m++) {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		} int m = 0; int m = 0; m 0 m < M m M m++ m++ m {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		} {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		} int c = 0; c 0 for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			} int n = 0; int n = 0; n 0 n < N n N n++ n++ n {
				if (A[n][m] == 1)
					c++;
			} {
				if (A[n][m] == 1)
					c++;
			} if (A[n][m] == 1)
					c++; A[n][m] == 1 A[n][m] A[n] A n m 1 c++ c if (c == N)
				ans++; c == N c N ans++ ans System.out.println(ans) System.out.println System.out System System.out ans
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	int M;

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
		A = new int[N][M];
	}

	public boolean hasNext() {
		return cnt < N;
	}

	int A[][];

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		int k = Integer.parseInt(strArr[0]);
		for (int i = 1; i <= k; i++) {
			A[cnt][Integer.parseInt(strArr[i]) - 1] = 1;
		}
		cnt++;
	}

	public void solve() {
		int ans = 0;
		for (int m = 0; m < M; m++) {
			int c = 0;
			for (int n = 0; n < N; n++) {
				if (A[n][m] == 1)
					c++;
			}
			if (c == N)
				ans++;
		}
		System.out.println(ans);
	}
}
