import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
 
 
 public   class Main {
    static class Reader
    {
    BufferedReader r;
    StringTokenizer str;
    Reader()
    {
    r=new BufferedReader(new InputStreamReader(System.in));
    }
    Reader(String fileName) throws FileNotFoundException
    {
    r=new BufferedReader(new FileReader(fileName));
    }
    public String getNextToken() throws IOException
    {
    if(str==null||!str.hasMoreTokens())
    {
    str=new StringTokenizer(r.readLine());
    }
    return str.nextToken();
    }
    public int nextInt() throws IOException
    {
    return Integer.parseInt(getNextToken());
    }
    public long nextLong() throws IOException
    {
    return Long.parseLong(getNextToken());
    }
    public double nextDouble() throws IOException
    {
    return Double.parseDouble(getNextToken());
    }
    public String nextString() throws IOException
    {
    return getNextToken();
    }
    public int[] intArray(int n) throws IOException
    {
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=nextInt();
        
        return a;
        
    }
    public long[] longArray(int n) throws IOException
    {
        long a[]=new long[n];
        for(int i=0;i<n;i++)
            a[i]=nextLong();
        
        return a;
        
    }
    public String[] stringArray(int n) throws IOException
    {
        String a[]=new String[n];
        for(int i=0;i<n;i++)
            a[i]=nextString();
        
        return a;
        
    }
    public long gcd(long a, long b) {
        if(b == 0){
        return a;
        }
        return gcd(b, a%b);
    }
    }
   
    
    public static void main(String args[]) throws IOException{
 
       Reader r =new Reader();
       PrintWriter pr=new PrintWriter(System.out,false);
       int n=r.nextInt();
       int k=r.nextInt();
       
       int a[]=new int[n+1];
       int count=0;
       
       for(int i=0;i<k;i++)
       {
           
           int m=r.nextInt();
           int c[]=r.intArray(m);
           int x=c[0];
           boolean b=false;
           for(int j=1;j<m;j++)
           {
               int y=c[j];
              
               a[x]=y;
               
               x=y;
              
           }
           

       }
       
       
     int j=1;
       for(int i=1;i<n;i++)
       {
           if(a[i]!=i+1)
               break;
           j++;
           
       }
       for(int i=j;i<n;i++)
       {
           count++;
           if(a[i]!=0)
               count++;
       }
       pr.println(count);
       
       pr.flush();
       pr.close();
       
    }
   
 }