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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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[] pos = new int[n + 1];

        List<List<Integer>> dollStack = new ArrayList<List<Integer>>();
        for (int i = 0; i < k; i++) {
            int m = in.nextInt();

            dollStack.add(new ArrayList<Integer>(m));

            for (int j = 0; j < m; j++) {
                int no = in.nextInt();
                pos[no] = i;
                dollStack.get(i).add(no);
            }
        }

        int sol = 0;
        int curr = 2;

        for (int i = 1; i < dollStack.get(pos[1]).size(); i++) {
            if (!dollStack.get(pos[1]).get(i).equals(curr)) {
                sol += dollStack.get(pos[1]).size() - i;

                for (int j = i; j < dollStack.get(pos[1]).size(); j++) {
                    pos[dollStack.get(pos[1]).get(j)] = -1;
                }

                break;
            }

            curr++;
        }

        while (curr <= n) {
            if (pos[curr] == -1) {
                sol++;
            } else {
                for (int j = dollStack.get(pos[curr]).size() - 1; j >= 0; j--) {
                    sol++;


                    if (dollStack.get(pos[curr]).get(j).equals(curr)) {
                        if (j == 0) {
                            sol--;
                        }

                        break;
                    } else {
                        pos[dollStack.get(pos[curr]).get(j)] = -1;
                    }
                }

                sol++;
            }

            curr++;
        }

        out.println(sol);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;


    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
    }

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

        return tokenizer.nextToken();
    }

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

}

