import java.io.*;
/**
 * Created by Vedant on 27/6/2015.
 */
public class matro {

    public static void main(String[] args)throws IOException{

        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String str[]= read.readLine().split(" ",2);

        int n = Integer.parseInt(str[0]);
        int k = Integer.parseInt(str[1]);

        boolean array[] = new boolean[n];

        int total = 0;

        int count = 0;

        for(int i = 0;i<k;i++){

            String str1[] = read.readLine().split(" ");

            int m = Integer.parseInt(str1[0]);

            int flag = 1;

            int r = Integer.parseInt(str1[1]);
            //System.out.println(r);

            if(r==1&&m>=2){
                int j = 2;

                while(j<str1.length){
                    int a = Integer.parseInt(str1[j]);
                    int b = Integer.parseInt(str1[j-1]);

                    if(a != b+1){
                        break;
                    }
                    else{
                        count = count+1;
                    }
                    j++;
                }

                //System.out.println(count);

                total = total+ m-1;
            }
            else if(str1[1]!="1"&&m>=2){

                total = total + m-1;
            }
            else{

            }


        }

        total  = total + n-1-(2*count);

        System.out.println(total);

    }
}
