import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  }

} Main static long t[]; t static long l[]; l static long h[]; h public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  } main {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  } BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1); r new BufferedReader(new InputStreamReader(System.in), 1) String s; s String sl[]; sl s = r.readLine() s r.readLine() r.readLine r sl = s.split(" ") sl s.split(" ") s.split s " " int n = Integer.parseInt(sl[0]); n Integer.parseInt(sl[0]) Integer.parseInt Integer sl[0] sl 0 int m = Integer.parseInt(sl[1]); m Integer.parseInt(sl[1]) Integer.parseInt Integer sl[1] sl 1 int a[] = new int[m]; a new int[m] m for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    } {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    } s = r.readLine() s r.readLine() r.readLine r sl = s.split(" ") sl s.split(" ") s.split s " " int v = Integer.parseInt(sl[0]); v Integer.parseInt(sl[0]) Integer.parseInt Integer sl[0] sl 0 for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      } int j = 1; int j = 1; j 1 j <= v j v j++ j++ j {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      } {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      } int t = Integer.parseInt(sl[j]) - 1; t Integer.parseInt(sl[j]) - 1 Integer.parseInt(sl[j]) Integer.parseInt Integer sl[j] sl j 1 a[t]++ a[t] a t int sum = 0; sum 0 for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    } {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    } if(a[i] == n)
      {
        sum++;
      } a[i] == n a[i] a i n {
        sum++;
      } sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  }

} public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    int a[] = new int[m];
    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]);
      for(int j = 1; j <= v; j++)
      {
        int t = Integer.parseInt(sl[j]) - 1;
        a[t]++;
      }
    }

    int sum = 0;
    for(int i = 0; i < m; i++)
    {
      //System.out.println(a[i]);
      if(a[i] == n)
      {
        sum++;
      }
    }
    System.out.println(sum);
  }

}