import java.io.*;
import java.util.*;
public class Problem556C
{
   boolean DEBUG=false;
   PrintWriter pw = new PrintWriter(System.out);
   BufferedReader br;
   StringTokenizer st;
   public static void main(String[] args) throws Exception
   {
      new Problem556C();
   }
   public Problem556C() throws Exception{
      main();
      pw.close();
   }   
   public void main() throws Exception{
      br = new BufferedReader(new InputStreamReader(System.in));
      st = getst(br);
      int n=nextInt(st);
      int k=nextInt(st);
      int correct=0;
      for(int i=0; i<k; i++)
      {
         st=getst(br);
         int r=nextInt(st);
         int[] arr=new int[r];
         for(int j=0; j<r; j++)
         {
            arr[j]=nextInt(st);
         }
         if(arr[0]!=1)
            continue;
         for(int j=0; j<r-1; j++)
         {
            if(arr[j]+1==arr[j+1]){
               correct++;
            }
            else 
               break;
         }
      }
      int stacks=n-1;
      int unstacks=n-k;
      pw.println(stacks-(correct*2)+unstacks);
      pw.close();
   }
   public static StringTokenizer getst(BufferedReader br) throws Exception{
      return new StringTokenizer(br.readLine(), " ");
   }
   public static int nextInt(StringTokenizer st) throws Exception{
      return Integer.parseInt(st.nextToken());
   }
}