import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	static PrintWriter pw;
	static int n;

	static long gcd(long n, long m) {
		return (m == 0 ? n : gcd(m, n % m));
	}
	static int[] gcd2(int p, int q) {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   }

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []count =new int[m+1];
		for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		}
		int c=0;
		for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		}
		pw.println(c);
		pw.flush();
				}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.lang.reflect.Array; Array java.lang.reflect import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.HashSet; HashSet java.util import java.util.PriorityQueue; PriorityQueue java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	static PrintWriter pw;
	static int n;

	static long gcd(long n, long m) {
		return (m == 0 ? n : gcd(m, n % m));
	}
	static int[] gcd2(int p, int q) {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   }

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []count =new int[m+1];
		for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		}
		int c=0;
		for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		}
		pw.println(c);
		pw.flush();
				}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
} Main static PrintWriter pw; pw static int n; n static long gcd(long n, long m) {
		return (m == 0 ? n : gcd(m, n % m));
	} gcd {
		return (m == 0 ? n : gcd(m, n % m));
	} return (m == 0 ? n : gcd(m, n % m)); (m == 0 ? n : gcd(m, n % m)) m == 0 m 0 n gcd(m, n % m) gcd m n % m n m long n n long m m static int[] gcd2(int p, int q) {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   } gcd2 {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   } if (q == 0)
	         return new int[] { p, 1, 0 }; q == 0 q 0 return new int[] { p, 1, 0 }; new int[] { p, 1, 0 } int[] vals = gcd2(q, p % q); vals gcd2(q, p % q) gcd2 q p % q p q int d = vals[0]; d vals[0] vals 0 int a = vals[2]; a vals[2] vals 2 int b = vals[1] - (p / q) * vals[2]; b vals[1] - (p / q) * vals[2] vals[1] vals 1 (p / q) * vals[2] (p / q) p q vals[2] vals 2 return new int[] { d, a, b }; new int[] { d, a, b } int p p int q q public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []count =new int[m+1];
		for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		}
		int c=0;
		for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		}
		pw.println(c);
		pw.flush();
				} main {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []count =new int[m+1];
		for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		}
		int c=0;
		for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		}
		pw.println(c);
		pw.flush();
				} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) pw = new PrintWriter(System.out) pw new PrintWriter(System.out) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int []count =new int[m+1]; count new int[m+1] m+1 m 1 for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		} int i =0; int i =0; i 0 i<n i n i++ i++ i {
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		} {
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc while(k-->0){
				count[sc.nextInt()]++;
			} k-->0 k-- k 0 {
				count[sc.nextInt()]++;
			} count[sc.nextInt()]++ count[sc.nextInt()] count sc.nextInt() sc.nextInt sc int c=0; c 0 for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		} int i =1; int i =1; i 1 i<=m i m i++ i++ i {
			if(count[i]==n)c++;
		} {
			if(count[i]==n)c++;
		} if(count[i]==n)c++; count[i]==n count[i] count i n c++ c pw.println(c) pw.println pw c pw.flush() pw.flush pw String[] args args static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	} Scanner StringTokenizer st; st BufferedReader br; br public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		} Scanner {
			br = new BufferedReader(new InputStreamReader(s));
		} br = new BufferedReader(new InputStreamReader(s)) br new BufferedReader(new InputStreamReader(s)) InputStream s s public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		} next {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		} while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine()); st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() throws IOException {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() throws IOException {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public String nextLine() throws IOException {
			return br.readLine();
		} nextLine {
			return br.readLine();
		} return br.readLine(); br.readLine() br.readLine br public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		} nextDouble {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		} String x = next(); x next() next StringBuilder sb = new StringBuilder("0"); sb new StringBuilder("0") double res = 0 res 0 f = 1; f 1 boolean dec = false dec false neg = false; neg false int start = 0; start 0 if (x.charAt(0) == '-') {
				neg = true;
				start++;
			} x.charAt(0) == '-' x.charAt(0) x.charAt x 0 '-' {
				neg = true;
				start++;
			} neg = true neg true start++ start for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				} int i = start; int i = start; i start i < x.length() i x.length() x.length x i++ i++ i if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				} if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				} x.charAt(i) == '.' x.charAt(i) x.charAt x i '.' {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} res = Long.parseLong(sb.toString()) res Long.parseLong(sb.toString()) Long.parseLong Long sb.toString() sb.toString sb sb = new StringBuilder("0") sb new StringBuilder("0") dec = true dec true {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				} sb.append(x.charAt(i)) sb.append sb x.charAt(i) x.charAt x i if (dec)
						f *= 10; dec f *= 10 f 10 res += Long.parseLong(sb.toString()) / f res Long.parseLong(sb.toString()) / f Long.parseLong(sb.toString()) Long.parseLong Long sb.toString() sb.toString sb f return res * (neg ? -1 : 1); res * (neg ? -1 : 1) res (neg ? -1 : 1) neg -1 1 1 public boolean ready() throws IOException {
			return br.ready();
		} ready {
			return br.ready();
		} return br.ready(); br.ready() br.ready br public class Main {
	static PrintWriter pw;
	static int n;

	static long gcd(long n, long m) {
		return (m == 0 ? n : gcd(m, n % m));
	}
	static int[] gcd2(int p, int q) {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   }

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []count =new int[m+1];
		for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		}
		int c=0;
		for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		}
		pw.println(c);
		pw.flush();
				}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
} public class Main {
	static PrintWriter pw;
	static int n;

	static long gcd(long n, long m) {
		return (m == 0 ? n : gcd(m, n % m));
	}
	static int[] gcd2(int p, int q) {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   }

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []count =new int[m+1];
		for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		}
		int c=0;
		for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		}
		pw.println(c);
		pw.flush();
				}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	static PrintWriter pw;
	static int n;

	static long gcd(long n, long m) {
		return (m == 0 ? n : gcd(m, n % m));
	}
	static int[] gcd2(int p, int q) {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   }

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int []count =new int[m+1];
		for(int i =0;i<n;i++){
			int k = sc.nextInt();
			while(k-->0){
				count[sc.nextInt()]++;
			}
		}
		int c=0;
		for(int i =1;i<=m;i++){
			if(count[i]==n)c++;
		}
		pw.println(c);
		pw.flush();
				}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}
