//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;
        for(int i=0;i<k;i++)
        {
            count=0;
            st=new StringTokenizer(br.readLine());
            int m=ip(st.nextToken());
            int[] a=new int[m];
            a[0]=ip(st.nextToken());
            for(int d=1;d<m;d++)
            {
                a[d]=ip(st.nextToken());
                if(a[d]-a[d-1]==1)
                {
                    count++;
                }
                
            }
            ans+=(m-1-count);
            count1+=(m-count);
        }
         ans=ans+(count1-1);
        pw.println(ans);
        pw.close();
    }
    public static int ip(String s)
    {
        return Integer.parseInt(s);
    }
    public static long lp(String s)
    {
        return Long.parseLong(s);
    }

}
