import java.io.InputStream;
import java.io.IOException;
import java.util.HashSet;

class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public int nextInt(){
        int ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
}

class Main {
    public static void main(String args[]) {
        MyScanner sc = new MyScanner();
        HashSet<Integer> set = new HashSet<Integer>();
        int n = sc.nextInt(), m = sc.nextInt();
        boolean[] selected = new boolean[m];
        for(int i = 0; i < m; i++){
            set.add(i);
        }
        
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        }
        System.out.println(set.size());
    }
} import java.io.InputStream; InputStream java.io import java.io.IOException; IOException java.io import java.util.HashSet; HashSet java.util class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public int nextInt(){
        int ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
} MyScanner InputStream stream; stream public MyScanner(){
        stream = System.in;
    } MyScanner {
        stream = System.in;
    } stream = System.in stream System.in System System.in public int nextInt(){
        int ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    } nextInt {
        int ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    } int ret = 0; ret 0 try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        } catch(IOException e){
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            return ret;
        } return ret; ret {
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        } while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            } true {
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            } char readed = (char)stream.read(); readed (char)stream.read() stream.read stream if(readed < '0' || readed > '9'){
                    break;
                } readed < '0' || readed > '9' readed < '0' readed '0' readed > '9' readed '9' {
                    break;
                } break; ret = ret * 10 + (readed - '0') ret ret * 10 + (readed - '0') ret * 10 ret 10 (readed - '0') readed '0' class Main {
    public static void main(String args[]) {
        MyScanner sc = new MyScanner();
        HashSet<Integer> set = new HashSet<Integer>();
        int n = sc.nextInt(), m = sc.nextInt();
        boolean[] selected = new boolean[m];
        for(int i = 0; i < m; i++){
            set.add(i);
        }
        
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        }
        System.out.println(set.size());
    }
} Main public static void main(String args[]) {
        MyScanner sc = new MyScanner();
        HashSet<Integer> set = new HashSet<Integer>();
        int n = sc.nextInt(), m = sc.nextInt();
        boolean[] selected = new boolean[m];
        for(int i = 0; i < m; i++){
            set.add(i);
        }
        
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        }
        System.out.println(set.size());
    } main {
        MyScanner sc = new MyScanner();
        HashSet<Integer> set = new HashSet<Integer>();
        int n = sc.nextInt(), m = sc.nextInt();
        boolean[] selected = new boolean[m];
        for(int i = 0; i < m; i++){
            set.add(i);
        }
        
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        }
        System.out.println(set.size());
    } MyScanner sc = new MyScanner(); sc new MyScanner() HashSet<Integer> set = new HashSet<Integer>(); set new HashSet<Integer>() int n = sc.nextInt() n sc.nextInt() sc.nextInt sc m = sc.nextInt(); m sc.nextInt() sc.nextInt sc boolean[] selected = new boolean[m]; selected new boolean[m] m for(int i = 0; i < m; i++){
            set.add(i);
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            set.add(i);
        } {
            set.add(i);
        } set.add(i) set.add set i for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        } {
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        } for(int j = 0; j < m; ++j){
                selected[j] = true;
            } int j = 0; int j = 0; j 0 j < m j m ++j ++j j {
                selected[j] = true;
            } {
                selected[j] = true;
            } selected[j] = true selected[j] selected j true int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            } int j = 0; int j = 0; j 0 j < c j c ++j ++j j {
                selected[sc.nextInt() - 1] = false;
            } {
                selected[sc.nextInt() - 1] = false;
            } selected[sc.nextInt() - 1] = false selected[sc.nextInt() - 1] selected sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 false for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            } int j = 0; int j = 0; j 0 j < m j m ++j ++j j {
                if(selected[j]){
                    set.remove(j);
                }
            } {
                if(selected[j]){
                    set.remove(j);
                }
            } if(selected[j]){
                    set.remove(j);
                } selected[j] selected j {
                    set.remove(j);
                } set.remove(j) set.remove set j System.out.println(set.size()) System.out.println System.out System System.out set.size() set.size set String args[] args
import java.io.InputStream;
import java.io.IOException;
import java.util.HashSet;

class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public int nextInt(){
        int ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
}

class Main {
    public static void main(String args[]) {
        MyScanner sc = new MyScanner();
        HashSet<Integer> set = new HashSet<Integer>();
        int n = sc.nextInt(), m = sc.nextInt();
        boolean[] selected = new boolean[m];
        for(int i = 0; i < m; i++){
            set.add(i);
        }
        
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                selected[j] = true;
            }
            int c = sc.nextInt();
            for(int j = 0; j < c; ++j){
                selected[sc.nextInt() - 1] = false;
            }
            for(int j = 0; j < m; ++j){
                if(selected[j]){
                    set.remove(j);
                }
            }
        }
        System.out.println(set.size());
    }
}
