/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
import java.io.*;
/**
 *
 * @author Alex
 */
public class C {
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int dolls = sc.nextInt();
        int lines = sc.nextInt();
        int dismantle = 0;
        int stacks = 0;
        int totalTime = 0;
        for(int i = 0;i<lines;i++){
            int elements = sc.nextInt();
            int previous = sc.nextInt();
            int len = 1;
            
            boolean broken = false;
            if(previous!=1) broken=true;
            for (int j = 1;j<elements;j++){
                int value = sc.nextInt();
                if(value == (previous+1) && broken == false) len++;
                else broken=true;
                previous = value;
            }
            dismantle += elements - len;
            stacks += elements-len+1;
        }
        totalTime = dismantle+stacks-1;
        out.println(totalTime);
        sc.close();
        out.close();
    }
}