
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.util.StringTokenizer;

public class Watermelon {
    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 long factorial(long number) {
        if (number <= 1)
           return 1;
        else
           return number * factorial(number - 1);
     }
    
    public static void main(String args[]) throws IOException{

       Reader r=new Reader();
       PrintWriter pr=new PrintWriter(System.out,false);

       int tot=r.nextInt();
       int chains=r.nextInt();
       int arr[]=new int[chains];
       int arr2[]=new int[chains];
       
       int old=0,curr=0,brkn=0,sum=0,add=0;
       for(int a=0;a<chains;a++)
       {
           arr[a]=r.nextInt();
           arr2[a]=arr[a];
           old=r.nextInt();
           for(int b=1;b<arr[a];b++)
           {
               if(old+1==(curr=r.nextInt())) arr2[a]--;
               old=curr;
           }
       }
       for(int i=0;i<chains;i++)
       {
           sum+=arr2[i];
       }
       brkn=sum-chains;
       add=sum-1;

      pr.print(brkn+add);
       
       pr.flush();
       pr.close();
       
    }
   
 }

