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

/**
 * Created by Юля on 14.09.2015.
 */
public class SolverC556 {
    public static void main(String[] args) throws IOException {
        new SolverC556().run();
    }

    BufferedReader br;
    PrintWriter pw;
    StringTokenizer tokenizer;

    public String nextToken() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() throws IOException, NumberFormatException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException, NumberFormatException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException, NumberFormatException {
        return Double.parseDouble(nextToken());
    }

    public void run() throws IOException {
//        br = new BufferedReader(new FileReader("input.txt"));
//        pw = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new OutputStreamWriter(System.out));

        solve();

        pw.flush();
        pw.close();
    }

    private void solve() throws IOException {
        int n=nextInt();
        int k=nextInt();

        int count=k;
        int countDiv=0;
        for(int i=0;i<k;i++){
            int m=nextInt();
            int tmp1=nextInt();
            for(int j=1;j<m;j++){
                int tmp2=nextInt();
                if(tmp2-tmp1!=1){
                    count+=1;
                    countDiv+=1;
                }
                tmp1=tmp2;
            }
        }

        pw.println(count+countDiv-1);

    }
}
