
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int m,k;
        m=sc.nextInt();
        k=sc.nextInt();
        int count=0, match=0;
        
        for(int i=0;i<k;i++){
            int linesize=sc.nextInt();
            int start=1;
            boolean found=false;
            for(int j=0;j<linesize;j++){
                if(sc.nextInt()==start){
                    start++;
                    match++;
                    found=true;
                }
                else
                    count++;
            }
            if(!found)
                count--;
        }
        System.out.println(count+(m-match));
    }

}
