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

public class asd
{
    public static void main(String [] args) throws IOException
    {
        MyScanner Reader = new MyScanner();
        int n = Reader.nextInt();
        int k = Reader.nextInt();
        int total = n-1;
        for (int i=0; i<k; i++)
        {
            int line = Reader.nextInt();
            int[] s = new int[line];
            total+=(line-1);
            for (int j=0; j<s.length; j++)
            {
                s[j] = Reader.nextInt();
            }
            int c = 1;
            int d = 0;
            boolean go = false;
            if (s[d] == c)
            {
                c++;
                d++;
                go = true;
            }
            
            
            while (go)
                {
                    if (d<line)
                    {
                        if (s[d] == c)
                        {
                            
                            total-=2;
                        
                        }
                        else
                        {
                            
                            break;
                        }
                    c++;
                    d++;
                    }
                    
                    else
                    {
                    
                    break;
                    }
                }
            
        }
        System.out.println(total);
        
    }
    
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
}

