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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String[] str = in.readLine().split(" "); str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int n = Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int m = Integer.parseInt(str[1]); m Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int a[] = new int[m]; a new int[m] m for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    } {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    } str = in.readLine().split(" ") str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int k = Integer.parseInt(str[0]); k Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      } int j=1; int j=1; j 1 j<=k j k j++ j++ j {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      } {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      } int t = Integer.parseInt(str[j]); t Integer.parseInt(str[j]) Integer.parseInt Integer str[j] str j a[t-1]++ a[t-1] a t-1 t 1 int count = 0; count 0 for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    } int i=0; int i=0; i 0 i<m i m i++ i++ i {
      if(a[i] == n)
        count++;
    } {
      if(a[i] == n)
        count++;
    } if(a[i] == n)
        count++; a[i] == n a[i] a i n count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  }
}