import java.util.Scanner;

public class D {
    public static void main(String cd[]){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        long ans=n-1+n-k;
        long chains=0;
        for(int i=0;i<k;i++){
            int m=in.nextInt();
            int nextchain=1;
            
            for(int j=0;j<m;j++){
            int a = in.nextInt();
             if (a == nextchain) {
                 chains = Math.max(chains, a);
                 ++nextchain;
             } else {
                 nextchain = -1;
             }
            }
        }
        System.out.println(ans-2*(chains-1));
    }
}