import 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[] K = new int[N];
    int[][] A = new int[N][M];
    int[] count = new int[M];
    int ans =0;
    for (int i=0; i<N; i++) {
      K[i] = sc.nextInt();
      for (int j=0; j<K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    }
    for (int i=1; i<=M; i++) {
      if (count[i-1] == N) ans++;
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public 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];
    int[] count = new int[M];
    int ans =0;
    for (int i=0; i<N; i++) {
      K[i] = sc.nextInt();
      for (int j=0; j<K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    }
    for (int i=1; i<=M; i++) {
      if (count[i-1] == 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[] K = new int[N];
    int[][] A = new int[N][M];
    int[] count = new int[M];
    int ans =0;
    for (int i=0; i<N; i++) {
      K[i] = sc.nextInt();
      for (int j=0; j<K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    }
    for (int i=1; i<=M; i++) {
      if (count[i-1] == N) 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];
    int[] count = new int[M];
    int ans =0;
    for (int i=0; i<N; i++) {
      K[i] = sc.nextInt();
      for (int j=0; j<K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    }
    for (int i=1; i<=M; i++) {
      if (count[i-1] == 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[] K = new int[N]; K new int[N] N int[][] A = new int[N][M]; A new int[N][M] N M int[] count = new int[M]; count new int[M] M int ans =0; ans 0 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 for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    } int i=1; int i=1; i 1 i<=M i M i++ i++ i {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    } {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    } for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      } int j=0; int j=0; j 0 j<N j N j++ j++ j {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      } {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      } for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        } int k=0; int k=0; k 0 k<K[j] k K[j] K j k++ k++ k {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        } {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        } if(A[j][k] == i) {
            count[i-1]++;
          } A[j][k] == i A[j][k] A[j] A j k i {
            count[i-1]++;
          } count[i-1]++ count[i-1] count i-1 i 1 for (int i=1; i<=M; i++) {
      if (count[i-1] == N) ans++;
    } int i=1; int i=1; i 1 i<=M i M i++ i++ i {
      if (count[i-1] == N) ans++;
    } {
      if (count[i-1] == N) ans++;
    } if (count[i-1] == N) ans++; count[i-1] == N count[i-1] count i-1 i 1 N 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[] K = new int[N];
    int[][] A = new int[N][M];
    int[] count = new int[M];
    int ans =0;
    for (int i=0; i<N; i++) {
      K[i] = sc.nextInt();
      for (int j=0; j<K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    }
    for (int i=1; i<=M; i++) {
      if (count[i-1] == 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[] K = new int[N];
    int[][] A = new int[N][M];
    int[] count = new int[M];
    int ans =0;
    for (int i=0; i<N; i++) {
      K[i] = sc.nextInt();
      for (int j=0; j<K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    }
    for (int i=1; i<=M; i++) {
      if (count[i-1] == N) ans++;
    }
    System.out.println(ans);
  }
} Main
import 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[] K = new int[N];
    int[][] A = new int[N][M];
    int[] count = new int[M];
    int ans =0;
    for (int i=0; i<N; i++) {
      K[i] = sc.nextInt();
      for (int j=0; j<K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=M; i++) {
      for (int j=0; j<N; j++) {
        for (int k=0; k<K[j]; k++) {
          if(A[j][k] == i) {
            count[i-1]++;
          }
        }
      }
    }
    for (int i=1; i<=M; i++) {
      if (count[i-1] == N) ans++;
    }
    System.out.println(ans);
  }
}