import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K[] = new int[N];
    int A[][] = new int[N][M];
    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    int ans = 0;
    if (N == 1) {
      System.out.println(K[0]);
      return;
    }
    for (int j = 0; j < A[0].length; j++) {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        ans++;
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K[] = new int[N];
    int A[][] = new int[N][M];
    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    int ans = 0;
    if (N == 1) {
      System.out.println(K[0]);
      return;
    }
    for (int j = 0; j < A[0].length; j++) {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        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 K[] = new int[N];
    int A[][] = new int[N][M];
    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    int ans = 0;
    if (N == 1) {
      System.out.println(K[0]);
      return;
    }
    for (int j = 0; j < A[0].length; j++) {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        ans++;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K[] = new int[N];
    int A[][] = new int[N][M];
    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    int ans = 0;
    if (N == 1) {
      System.out.println(K[0]);
      return;
    }
    for (int j = 0; j < A[0].length; j++) {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        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 K[] = new int[N]; K new int[N] N int A[][] = new int[N][M]; A new int[N][M] N M for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    } {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    } K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      } int j = 0; int j = 0; j 0 j < K[i] j K[i] K i j++ j++ j {
        A[i][j] = sc.nextInt();
      } {
        A[i][j] = sc.nextInt();
      } A[i][j] = sc.nextInt() A[i][j] A[i] A i j sc.nextInt() sc.nextInt sc int ans = 0; ans 0 if (N == 1) {
      System.out.println(K[0]);
      return;
    } N == 1 N 1 {
      System.out.println(K[0]);
      return;
    } System.out.println(K[0]) System.out.println System.out System System.out K[0] K 0 return; for (int j = 0; j < A[0].length; j++) {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        ans++;
      }
    } int j = 0; int j = 0; j 0 j < A[0].length j A[0].length A[0] A 0 A[0].length j++ j++ j {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        ans++;
      }
    } {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        ans++;
      }
    } int tmp = A[0][j]; tmp A[0][j] A[0] A 0 j int count = 0; count 0 for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      } {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      } for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        } int k = 0; int k = 0; k 0 k < K[i] k K[i] K i k++ k++ k {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        } {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        } if (A[i][k] == 0) {
            break;
          } A[i][k] == 0 A[i][k] A[i] A i k 0 {
            break;
          } break; if (tmp == A[i][k]) {
            count++;
            break;
          } tmp == A[i][k] tmp A[i][k] A[i] A i k {
            count++;
            break;
          } count++ count break; if (count == N - 1) {
        ans++;
      } count == N - 1 count N - 1 N 1 {
        ans++;
      } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K[] = new int[N];
    int A[][] = new int[N][M];
    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    int ans = 0;
    if (N == 1) {
      System.out.println(K[0]);
      return;
    }
    for (int j = 0; j < A[0].length; j++) {
      int tmp = A[0][j];
      int count = 0;
      for (int i = 1; i < N; i++) {
        for (int k = 0; k < K[i]; k++) {
          if (A[i][k] == 0) {
            break;
          }
          if (tmp == A[i][k]) {
            count++;
            break;
          }
        }
      }
      if (count == N - 1) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}