import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] cnt = new int[M];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    }
    for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java import java.util.Collections; Collections java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] cnt = new int[M];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    }
    for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] cnt = new int[M];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    }
    for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] cnt = new int[M];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    }
    for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] cnt = new int[M]; cnt new int[M] M int ans = 0; ans 0 for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    } {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    } int roop = sc.nextInt(); roop sc.nextInt() sc.nextInt sc for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      } int j = 0; int j = 0; j 0 j < roop j roop j++ j++ j {
        cnt[sc.nextInt() - 1]++;
      } {
        cnt[sc.nextInt() - 1]++;
      } cnt[sc.nextInt() - 1]++ cnt[sc.nextInt() - 1] cnt sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
      if (cnt[i] == N) {
        ans++;
      }
    } {
      if (cnt[i] == N) {
        ans++;
      }
    } if (cnt[i] == N) {
        ans++;
      } cnt[i] == N cnt[i] cnt i N {
        ans++;
      } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] cnt = new int[M];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    }
    for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] cnt = new int[M];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    }
    for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    }
    System.out.println(ans);
  }
} Main
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] cnt = new int[M];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int roop = sc.nextInt();
      for (int j = 0; j < roop; j++) {
        cnt[sc.nextInt() - 1]++;
      }
    }
    for (int i = 0; i < M; i++) {
      if (cnt[i] == N) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}
