import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class C {


    public static void main(String[] args) throws IOException {
        InputScanner is = new InputScanner();
        int numberOfDolls = is.nextInt();
        int numberOfChains = is.nextInt();
        int[][] chains = new int[numberOfChains][];
        for (int i = 0; i < numberOfChains; i++) {
            int c = is.nextInt();
            chains[i] = new int[c];
            for (int j = 0; j < c; j++) {
                chains[i][j] = is.nextInt();
            }
        }

        int[] subseq = new int[numberOfChains];
        for (int i = 0; i < numberOfChains; i++) {
            int num = 1;
            int tmp = chains[i][0];
            for (int j = 1; j < chains[i].length; j++) {
                if (chains[i][j] - 1 != tmp) num++;
                tmp = chains[i][j];
            }
            subseq[i] = num;
        }
        int x = 0;
        int y = 0;
        for (int i = 0; i < subseq.length; i++){
            x += (subseq[i] - 1);
            y += subseq[i];
        }
        System.out.println(x+y-1);
    }

    static class InputScanner {

        BufferedReader br;
        StringTokenizer st;

        public InputScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        public int nextInt() throws IOException {
            String next = next();
            return Integer.parseInt(next);
        }

        public long nextLong() throws IOException {
            String next = next();
            return Long.parseLong(next);
        }
    }
}
