import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Bat-Orgil
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n=in.nextInt();
        int k =in.nextInt();
        int[][] chain= new int[k][];
        int ind=-1;
        for(int i=0; i<k; i++){
            chain[i]= new int[in.nextInt()];
            for(int j=0; j<chain[i].length; j++){
                chain[i][j]=in.nextInt();
                if(chain[i][j]==1){
                    ind=i;
                }
            }
        }
        int count=1;
        for(int j=1; j<chain[ind].length; j++){
            if(chain[ind][j]== chain[ind][j-1]+1){
                count++;
            }else{
                break;
            }
        }
        int answer=0;
        answer+= chain[ind].length-count;
        for(int i=0; i<k; i++){
            if(i!= ind){
                answer+= chain[i].length-1;
            }
        }
        answer+= (n-count);
        out.println(answer);




    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}

