import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    }
  }
} Main public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    }
  } main {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    }
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    } in.hasNext() in.hasNext in {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    } int N = in.nextInt(); N in.nextInt() in.nextInt in int M = in.nextInt(); M in.nextInt() in.nextInt in int[] A = new int[M]; A new int[M] M for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      } int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      } {
        int K = in.nextInt();

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

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    }
  }
} public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int[] A = new int[M];

      for (int i = 0; i < N; ++i) {
        int K = in.nextInt();

        for (int j = 0; j < K; ++j) {
          ++A[in.nextInt() - 1];
        }
      }
      
      int count = 0;
      for (int i = 0; i < A.length; ++i) {
        if (A[i] == N) {
          ++count;
        }
      }

      System.out.println(count);
    }
  }
}