import java.io.*;
import java.util.*;

public class Main {
	  public static void main(String[] args) {
	        InputStream inputStream = System.in;
	        OutputStream outputStream = System.out;
	        InputReader in = new InputReader(inputStream);
	            try (PrintWriter out = new PrintWriter(outputStream)) {
	            	TaskC solver = new TaskC();
	                solver.solve(in, out);
	            }
	    }
}
class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream inputstream) {
      reader = new BufferedReader(new InputStreamReader(inputstream));
      tokenizer = null;
    }
    
    public String nextLine(){
    	String fullLine=null;
    	while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
              fullLine=reader.readLine();
            } catch (IOException e) {
              throw new RuntimeException(e);
            }
            return fullLine;
          }
          return fullLine;
    }
	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 long nextLong() {
	      return Long.parseLong(next());
	    }
    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
class TaskC {
	void solve(InputReader in,PrintWriter out){
		int n=in.nextInt();
		int k=in.nextInt();
		long max=1;
		long ans=0;
		for(int i=0;i<k;i++){
			int s=in.nextInt();
			ans+=s-1;
			int tmp[]=new int[s];
			for(int j=0;j<s;j++){
				tmp[j]=in.nextInt();
			}
			long count=1;
			for(int j=0;j<s-1;j++){
				count++;
				if(tmp[j+1]==tmp[j]+1){
					max=Math.max(max, count);
				}
				else{
					count=1;
				}
			}
		}
		out.println(ans+n-max-max+1);
	}
}
