import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} Main public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  } main {
    Scanner reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  } Scanner reader = new Scanner(System.in); reader new Scanner(System.in) Scanner nLine = new Scanner(reader.nextLine()); nLine new Scanner(reader.nextLine()) int n = nLine.nextInt(); n nLine.nextInt() nLine.nextInt nLine int m = nLine.nextInt(); m nLine.nextInt() nLine.nextInt nLine int[] unique = new int[31]; unique new int[31] 31 int count = 0; count 0 while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    } reader.hasNextLine() reader.hasNextLine reader {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    } Scanner line = new Scanner(reader.nextLine()); line new Scanner(reader.nextLine()) int base = line.nextInt(); base line.nextInt() line.nextInt line while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      } base > 0 base 0 {
        int i = line.nextInt();
        unique[i]++;
        base--;
      } int i = line.nextInt(); i line.nextInt() line.nextInt line unique[i]++ unique[i] unique i base-- base for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    } int i = 0; int i = 0; i 0 i <= m i m ++i ++i i {
      if(unique[i] == n) {
        count++;
      }
    } {
      if(unique[i] == n) {
        count++;
      }
    } if(unique[i] == n) {
        count++;
      } unique[i] == n unique[i] unique i 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 reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  }
}
