import java.util.*;

public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} import java.util.*; util.* java public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} Main public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  } main {
    final Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  } final Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    } {
      scanner.close();
    } scanner.close() scanner.close scanner {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int m = scanner.nextInt(); m scanner.nextInt() scanner.nextInt scanner int[] cnt = new int[m]; cnt new int[m] m for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      } {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      } int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        } {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        } int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner a-- a cnt[a]++ cnt[a] cnt a int ans = 0; ans 0 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 System.out.println(ans) System.out.println System.out System System.out ans final String[] args args public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} Main
import java.util.*;

public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] cnt = new int[m]; // 食べ物別に好きな人数を集計する

      for (int i = 0; i < n; i++) {
        int k = scanner.nextInt();
        for (int j = 0; j < k; j++) {
          int a = scanner.nextInt();
          a--;
          cnt[a]++;
        }
      }

      int ans = 0;
      for (int i = 0; i < m; i++) {
        if (cnt[i] == n) ans++;
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
}
