import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] input = br.readLine().split(" ");

          int N = Integer.parseInt(input[0]);
          int K = Integer.parseInt(input[1]);

          int[] result = new int[N];
          int d = 0;

          for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          }

          int min = 0;
          int count = 0;

          for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          }


          for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          }

          System.out.println(count);
      }
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] input = br.readLine().split(" ");

          int N = Integer.parseInt(input[0]);
          int K = Integer.parseInt(input[1]);

          int[] result = new int[N];
          int d = 0;

          for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          }

          int min = 0;
          int count = 0;

          for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          }


          for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          }

          System.out.println(count);
      }
    }
} Main public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] input = br.readLine().split(" ");

          int N = Integer.parseInt(input[0]);
          int K = Integer.parseInt(input[1]);

          int[] result = new int[N];
          int d = 0;

          for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          }

          int min = 0;
          int count = 0;

          for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          }


          for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          }

          System.out.println(count);
      }
    } main {
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] input = br.readLine().split(" ");

          int N = Integer.parseInt(input[0]);
          int K = Integer.parseInt(input[1]);

          int[] result = new int[N];
          int d = 0;

          for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          }

          int min = 0;
          int count = 0;

          for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          }


          for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          }

          System.out.println(count);
      }
    } try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] input = br.readLine().split(" ");

          int N = Integer.parseInt(input[0]);
          int K = Integer.parseInt(input[1]);

          int[] result = new int[N];
          int d = 0;

          for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          }

          int min = 0;
          int count = 0;

          for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          }


          for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          }

          System.out.println(count);
      } {
          String[] input = br.readLine().split(" ");

          int N = Integer.parseInt(input[0]);
          int K = Integer.parseInt(input[1]);

          int[] result = new int[N];
          int d = 0;

          for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          }

          int min = 0;
          int count = 0;

          for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          }


          for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          }

          System.out.println(count);
      } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int N = Integer.parseInt(input[0]); N Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int K = Integer.parseInt(input[1]); K Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 int[] result = new int[N]; result new int[N] N int d = 0; d 0 for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          } {
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          } d = Integer.parseInt(br.readLine()) d Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String[] tmp = br.readLine().split(" "); tmp br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            } int j = 0; int j = 0; j 0 j < d j d j++ j++ j {
              result[Integer.parseInt(tmp[j])-1] += 1;
            } {
              result[Integer.parseInt(tmp[j])-1] += 1;
            } result[Integer.parseInt(tmp[j])-1] += 1 result[Integer.parseInt(tmp[j])-1] result Integer.parseInt(tmp[j])-1 Integer.parseInt(tmp[j]) Integer.parseInt Integer tmp[j] tmp j 1 1 int min = 0; min 0 int count = 0; count 0 for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          } int i = 0; int i = 0; i 0 i < result.length i result.length result result.length i++ i++ i {
            if(min > result[i]){
              min = result[i];
            }
          } {
            if(min > result[i]){
              min = result[i];
            }
          } if(min > result[i]){
              min = result[i];
            } min > result[i] min result[i] result i {
              min = result[i];
            } min = result[i] min result[i] result i for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          } int i = 0; int i = 0; i 0 i < result.length i result.length result result.length i++ i++ i {
            if(min == result[i]){
              count++;
            }
          } {
            if(min == result[i]){
              count++;
            }
          } if(min == result[i]){
              count++;
            } min == result[i] min result[i] result i {
              count++;
            } count++ count System.out.println(count) System.out.println System.out System System.out count String args[] args
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] input = br.readLine().split(" ");

          int N = Integer.parseInt(input[0]);
          int K = Integer.parseInt(input[1]);

          int[] result = new int[N];
          int d = 0;

          for(int i = 0; i < K; i++){
            d = Integer.parseInt(br.readLine());
            String[] tmp = br.readLine().split(" ");
           
            for(int j = 0; j < d; j++){
              result[Integer.parseInt(tmp[j])-1] += 1;
            }
          }

          int min = 0;
          int count = 0;

          for(int i = 0; i < result.length; i++){
            if(min > result[i]){
              min = result[i];
            }
          }


          for(int i = 0; i < result.length; i++){
            if(min == result[i]){
              count++;
            }
          }

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