import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] mList = new int[m];
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    }
    int count = 0;
    for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} import java.util.Scanner; Scanner 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[] mList = new int[m];
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    }
    int count = 0;
    for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] mList = new int[m];
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    }
    int count = 0;
    for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    }
    System.out.print(count);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] mList = new int[m];
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    }
    int count = 0;
    for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    }
    System.out.print(count);
  } 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[] mList = new int[m]; mList new int[m] m for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    } {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
          int a = sc.nextInt();
          mList[a - 1]++;
        } {
          int a = sc.nextInt();
          mList[a - 1]++;
        } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc mList[a - 1]++ mList[a - 1] mList a - 1 a 1 int count = 0; count 0 for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    } int mm mList {
      if (mm == n) {
        count++;
      }
    } {
      if (mm == n) {
        count++;
      }
    } if (mm == n) {
        count++;
      } mm == n mm n {
        count++;
      } count++ count System.out.print(count) System.out.print System.out System System.out count 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[] mList = new int[m];
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    }
    int count = 0;
    for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] mList = new int[m];
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    }
    int count = 0;
    for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] mList = new int[m];
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          int a = sc.nextInt();
          mList[a - 1]++;
        }
    }
    int count = 0;
    for (int mm : mList) {
      if (mm == n) {
        count++;
      }
    }
    System.out.print(count);
  }
}