//package codeforcesround310;
import java.io.*;
import java.util.*;
public class q3 {
    public static void main(String[] args) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int k=ip(st.nextToken());
        int count=0;
        int count1=0;
        int ans=0;
        int len=1;
        for(int i=0;i<k;i++)
        {
            st=new StringTokenizer(br.readLine());
            int m=ip(st.nextToken());
            int[] a=new int[m];
            a[0]=ip(st.nextToken());
            count+=(m-1);
            
            
            if(a[0]==1)
            {
                for(int f=1;f<m;f++)
                {
                    a[f]=ip(st.nextToken());
                }
                int d=1;
                while(d<m && a[d]==a[d-1]+1  )
                {
                    //System.out.println("here");
                    len++;
                    d++;
                    
                }
            }
    
        }
        //System.out.println("len is"+len);
        count+=(n-1);
        count-=2*(len-1);
        pw.println(count);
        pw.close();
    }
    public static int ip(String s)
    {
        return Integer.parseInt(s);
    }
    public static long lp(String s)
    {
        return Long.parseLong(s);
    }

}
