import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	static int n;
	static long k;
	static long[] a;
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m + 1];

		int i,j,k;
		for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		}

		long ans = 0;
		for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++;

		out.print(ans);
		out.close();
	}
}
class cal{
	long mod;

	cal(long x){
		this.mod = x;
	}
	long mpow(long x, long n) {
		if(n == 0)
			return 1;
		if(n % 2 == 0) {
			long root = mpow(x, n / 2);
			return root * root % mod;
		}else {
			return x * mpow(x, n - 1) % mod;
		}
	}

	long mcomb(long a, long b) {
		if(b > a - b)
			return mcomb(a, a - b);
		long m = 1;
		long d = 1;
		long i;
		for(i = 0; i < b; i++) {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		}
		long ans = m * mpow(d, mod - 2) % mod;

		return ans;
	}
}
class unionFind{
	int[] par;
	int[] size;

	unionFind(int x){
		this.par = new int[x + 1];
		this.size = new int[x + 1];

		int i;
		for(i = 0; i <= x; i++)
			this.par[i] = i;
		Arrays.fill(this.size, 1);
	}

	int root(int x) {
		int r = x;
		while (r != this.par[r]) {
	        r = this.par[r];
	      }

		return r;
	}

	void union(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return;

		if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		}
	}

	int size(int x) {
		return this.size[root(x)];
	}

	boolean same(int x, int y) {
		int rx = root(x);
		int ry = root(y);

		return rx == ry;
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
} import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.NoSuchElementException; NoSuchElementException java.util public class Main {

	static int n;
	static long k;
	static long[] a;
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m + 1];

		int i,j,k;
		for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		}

		long ans = 0;
		for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++;

		out.print(ans);
		out.close();
	}
} Main static int n; n static long k; k static long[] a; a public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m + 1];

		int i,j,k;
		for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		}

		long ans = 0;
		for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++;

		out.print(ans);
		out.close();
	} main {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m + 1];

		int i,j,k;
		for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		}

		long ans = 0;
		for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++;

		out.print(ans);
		out.close();
	} FastScanner scan = new FastScanner(); scan new FastScanner() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int[] a = new int[m + 1]; a new int[m + 1] m + 1 m 1 int i i j j k; k for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		} i = 0; i = 0 i 0 i < n i n i++ i++ i {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		} {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		} k = scan.nextInt() k scan.nextInt() scan.nextInt scan for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			} j = 0; j = 0 j 0 j < k j k j++ j++ j {
				a[scan.nextInt()]++;
			} {
				a[scan.nextInt()]++;
			} a[scan.nextInt()]++ a[scan.nextInt()] a scan.nextInt() scan.nextInt scan long ans = 0; ans 0 for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++; i = 1; i = 1 i 1 i <= m i m i++ i++ i if(a[i] == n)
				ans++; if(a[i] == n)
				ans++; a[i] == n a[i] a i n ans++ ans out.print(ans) out.print out ans out.close() out.close out String[] args args class cal{
	long mod;

	cal(long x){
		this.mod = x;
	}
	long mpow(long x, long n) {
		if(n == 0)
			return 1;
		if(n % 2 == 0) {
			long root = mpow(x, n / 2);
			return root * root % mod;
		}else {
			return x * mpow(x, n - 1) % mod;
		}
	}

	long mcomb(long a, long b) {
		if(b > a - b)
			return mcomb(a, a - b);
		long m = 1;
		long d = 1;
		long i;
		for(i = 0; i < b; i++) {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		}
		long ans = m * mpow(d, mod - 2) % mod;

		return ans;
	}
} cal long mod; mod cal(long x){
		this.mod = x;
	} cal {
		this.mod = x;
	} this.mod = x this.mod this this.mod x long x x long mpow(long x, long n) {
		if(n == 0)
			return 1;
		if(n % 2 == 0) {
			long root = mpow(x, n / 2);
			return root * root % mod;
		}else {
			return x * mpow(x, n - 1) % mod;
		}
	} mpow {
		if(n == 0)
			return 1;
		if(n % 2 == 0) {
			long root = mpow(x, n / 2);
			return root * root % mod;
		}else {
			return x * mpow(x, n - 1) % mod;
		}
	} if(n == 0)
			return 1; n == 0 n 0 return 1; 1 if(n % 2 == 0) {
			long root = mpow(x, n / 2);
			return root * root % mod;
		}else {
			return x * mpow(x, n - 1) % mod;
		} n % 2 == 0 n % 2 n 2 0 {
			long root = mpow(x, n / 2);
			return root * root % mod;
		} long root = mpow(x, n / 2); root mpow(x, n / 2) mpow x n / 2 n 2 return root * root % mod; root * root % mod root * root root root mod {
			return x * mpow(x, n - 1) % mod;
		} return x * mpow(x, n - 1) % mod; x * mpow(x, n - 1) % mod x * mpow(x, n - 1) x mpow(x, n - 1) mpow x n - 1 n 1 mod long x x long n n long mcomb(long a, long b) {
		if(b > a - b)
			return mcomb(a, a - b);
		long m = 1;
		long d = 1;
		long i;
		for(i = 0; i < b; i++) {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		}
		long ans = m * mpow(d, mod - 2) % mod;

		return ans;
	} mcomb {
		if(b > a - b)
			return mcomb(a, a - b);
		long m = 1;
		long d = 1;
		long i;
		for(i = 0; i < b; i++) {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		}
		long ans = m * mpow(d, mod - 2) % mod;

		return ans;
	} if(b > a - b)
			return mcomb(a, a - b); b > a - b b a - b a b return mcomb(a, a - b); mcomb(a, a - b) mcomb a a - b a b long m = 1; m 1 long d = 1; d 1 long i; i for(i = 0; i < b; i++) {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		} i = 0; i = 0 i 0 i < b i b i++ i++ i {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		} {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		} m *= (a - i) m (a - i) a i m %= mod m mod d *= (i + 1) d (i + 1) i 1 d %= mod d mod long ans = m * mpow(d, mod - 2) % mod; ans m * mpow(d, mod - 2) % mod m * mpow(d, mod - 2) m mpow(d, mod - 2) mpow d mod - 2 mod 2 mod return ans; ans long a a long b b class unionFind{
	int[] par;
	int[] size;

	unionFind(int x){
		this.par = new int[x + 1];
		this.size = new int[x + 1];

		int i;
		for(i = 0; i <= x; i++)
			this.par[i] = i;
		Arrays.fill(this.size, 1);
	}

	int root(int x) {
		int r = x;
		while (r != this.par[r]) {
	        r = this.par[r];
	      }

		return r;
	}

	void union(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return;

		if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		}
	}

	int size(int x) {
		return this.size[root(x)];
	}

	boolean same(int x, int y) {
		int rx = root(x);
		int ry = root(y);

		return rx == ry;
	}
} unionFind int[] par; par int[] size; size unionFind(int x){
		this.par = new int[x + 1];
		this.size = new int[x + 1];

		int i;
		for(i = 0; i <= x; i++)
			this.par[i] = i;
		Arrays.fill(this.size, 1);
	} unionFind {
		this.par = new int[x + 1];
		this.size = new int[x + 1];

		int i;
		for(i = 0; i <= x; i++)
			this.par[i] = i;
		Arrays.fill(this.size, 1);
	} this.par = new int[x + 1] this.par this this.par new int[x + 1] x + 1 x 1 this.size = new int[x + 1] this.size this this.size new int[x + 1] x + 1 x 1 int i; i for(i = 0; i <= x; i++)
			this.par[i] = i; i = 0; i = 0 i 0 i <= x i x i++ i++ i this.par[i] = i; this.par[i] = i this.par[i] this.par this this.par i i Arrays.fill(this.size, 1) Arrays.fill Arrays this.size this this.size 1 int x x int root(int x) {
		int r = x;
		while (r != this.par[r]) {
	        r = this.par[r];
	      }

		return r;
	} root {
		int r = x;
		while (r != this.par[r]) {
	        r = this.par[r];
	      }

		return r;
	} int r = x; r x while (r != this.par[r]) {
	        r = this.par[r];
	      } r != this.par[r] r this.par[r] this.par this this.par r {
	        r = this.par[r];
	      } r = this.par[r] r this.par[r] this.par this this.par r return r; r int x x void union(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return;

		if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		}
	} union {
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return;

		if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		}
	} int rx = root(x); rx root(x) root x int ry = root(y); ry root(y) root y if(rx == ry)
			return; rx == ry rx ry return; if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		} this.size[rx] < this.size[ry] this.size[rx] this.size this this.size rx this.size[ry] this.size this this.size ry {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		} this.size[ry] += this.size[rx] this.size[ry] this.size this this.size ry this.size[rx] this.size this this.size rx this.par[rx] = ry this.par[rx] this.par this this.par rx ry {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		} this.size[rx] += this.size[ry] this.size[rx] this.size this this.size rx this.size[ry] this.size this this.size ry this.par[ry] = rx this.par[ry] this.par this this.par ry rx int x x int y y int size(int x) {
		return this.size[root(x)];
	} size {
		return this.size[root(x)];
	} return this.size[root(x)]; this.size[root(x)] this.size this this.size root(x) root x int x x boolean same(int x, int y) {
		int rx = root(x);
		int ry = root(y);

		return rx == ry;
	} same {
		int rx = root(x);
		int ry = root(y);

		return rx == ry;
	} int rx = root(x); rx root(x) root x int ry = root(y); ry root(y) root y return rx == ry; rx == ry rx ry int x x int y y class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
} FastScanner private final InputStream in = System.in; in System.in System System.in private final byte[] buffer = new byte[1024]; buffer new byte[1024] 1024 private int ptr = 0; ptr 0 private int buflen = 0; buflen 0 private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    } hasNextByte {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    } if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        } ptr < buflen ptr buflen {
            return true;
        } return true; true {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        } ptr = 0 ptr 0 try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                buflen = in.read(buffer);
            } buflen = in.read(buffer) buflen in.read(buffer) in.read in buffer if (buflen <= 0) {
                return false;
            } buflen <= 0 buflen 0 {
                return false;
            } return false; false return true; true private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} readByte { if (hasNextByte()) return buffer[ptr++]; else return -1;} if (hasNextByte()) return buffer[ptr++]; else return -1; hasNextByte() hasNextByte return buffer[ptr++]; buffer[ptr++] buffer ptr++ ptr return -1; -1 1 private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} isPrintableChar { return 33 <= c && c <= 126;} return 33 <= c && c <= 126; 33 <= c && c <= 126 33 <= c 33 c c <= 126 c 126 int c c public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();} hasNext { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();} while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; hasNextByte() && !isPrintableChar(buffer[ptr]) hasNextByte() hasNextByte !isPrintableChar(buffer[ptr]) isPrintableChar(buffer[ptr]) isPrintableChar buffer[ptr] buffer ptr ptr++ ptr return hasNextByte(); hasNextByte() hasNextByte public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    } next {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    } if (!hasNext()) throw new NoSuchElementException(); !hasNext() hasNext() hasNext throw new NoSuchElementException(); new NoSuchElementException() StringBuilder sb = new StringBuilder(); sb new StringBuilder() int b = readByte(); b readByte() readByte while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        } isPrintableChar(b) isPrintableChar b {
            sb.appendCodePoint(b);
            b = readByte();
        } sb.appendCodePoint(b) sb.appendCodePoint sb b b = readByte() b readByte() readByte return sb.toString(); sb.toString() sb.toString sb public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    } nextLong {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    } if (!hasNext()) throw new NoSuchElementException(); !hasNext() hasNext() hasNext throw new NoSuchElementException(); new NoSuchElementException() long n = 0; n 0 boolean minus = false; minus false int b = readByte(); b readByte() readByte if (b == '-') {
            minus = true;
            b = readByte();
        } b == '-' b '-' {
            minus = true;
            b = readByte();
        } minus = true minus true b = readByte() b readByte() readByte if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        } b < '0' || '9' < b b < '0' b '0' '9' < b '9' b {
            throw new NumberFormatException();
        } throw new NumberFormatException(); new NumberFormatException() while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        } true {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        } if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            } '0' <= b && b <= '9' '0' <= b '0' b b <= '9' b '9' {
                n *= 10;
                n += b - '0';
            } n *= 10 n 10 n += b - '0' n b - '0' b '0' if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            } b == -1 || !isPrintableChar(b) b == -1 b -1 1 !isPrintableChar(b) isPrintableChar(b) isPrintableChar b {
                return minus ? -n : n;
            } return minus ? -n : n; minus ? -n : n minus -n n n {
                throw new NumberFormatException();
            } throw new NumberFormatException(); new NumberFormatException() b = readByte() b readByte() readByte public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    } nextInt {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    } long nl = nextLong(); nl nextLong() nextLong if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE nl < Integer.MIN_VALUE nl Integer.MIN_VALUE Integer Integer.MIN_VALUE nl > Integer.MAX_VALUE nl Integer.MAX_VALUE Integer Integer.MAX_VALUE throw new NumberFormatException(); new NumberFormatException() return (int) nl; (int) nl public double nextDouble() { return Double.parseDouble(next());} nextDouble { return Double.parseDouble(next());} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public class Main {

	static int n;
	static long k;
	static long[] a;
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m + 1];

		int i,j,k;
		for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		}

		long ans = 0;
		for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++;

		out.print(ans);
		out.close();
	}
} public class Main {

	static int n;
	static long k;
	static long[] a;
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m + 1];

		int i,j,k;
		for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		}

		long ans = 0;
		for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++;

		out.print(ans);
		out.close();
	}
} Main
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	static int n;
	static long k;
	static long[] a;
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m + 1];

		int i,j,k;
		for(i = 0; i < n; i++) {
			k = scan.nextInt();
			for(j = 0; j < k; j++) {
				a[scan.nextInt()]++;
			}
		}

		long ans = 0;
		for(i = 1; i <= m; i++)
			if(a[i] == n)
				ans++;

		out.print(ans);
		out.close();
	}
}
class cal{
	long mod;

	cal(long x){
		this.mod = x;
	}
	long mpow(long x, long n) {
		if(n == 0)
			return 1;
		if(n % 2 == 0) {
			long root = mpow(x, n / 2);
			return root * root % mod;
		}else {
			return x * mpow(x, n - 1) % mod;
		}
	}

	long mcomb(long a, long b) {
		if(b > a - b)
			return mcomb(a, a - b);
		long m = 1;
		long d = 1;
		long i;
		for(i = 0; i < b; i++) {
			m *= (a - i);
			m %= mod;
			d *= (i + 1);
			d %= mod;
		}
		long ans = m * mpow(d, mod - 2) % mod;

		return ans;
	}
}
class unionFind{
	int[] par;
	int[] size;

	unionFind(int x){
		this.par = new int[x + 1];
		this.size = new int[x + 1];

		int i;
		for(i = 0; i <= x; i++)
			this.par[i] = i;
		Arrays.fill(this.size, 1);
	}

	int root(int x) {
		int r = x;
		while (r != this.par[r]) {
	        r = this.par[r];
	      }

		return r;
	}

	void union(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return;

		if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		}
	}

	int size(int x) {
		return this.size[root(x)];
	}

	boolean same(int x, int y) {
		int rx = root(x);
		int ry = root(y);

		return rx == ry;
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
