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

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);
            solve(in, out);
            out.close();
    }
        
        public static void solve(InputReader in, PrintWriter out){
            int n, k;
            n = in.nextInt();
            k = in.nextInt();
            int tp=0;
            int cnt = 0, ans = 0,sm=0;
            for(int i = 0; i < k; ++i){
                int m, j;
                cnt = 0;
                m = in.nextInt();
                ans += (m-1);
                int[] d = new int[m];
                for(j = 0; j < m; ++j){
                    d[j] = in.nextInt();
                }
                if(d[0] == 1){
                    j = 1;
                    while(j < m && d[j] == d[j-1]+1)
                    {
                        j++;
                        tp++;       
                    }
                }
            }
            //out.println(tp + " " + ans);
            ans += (n-1);
            ans -= 2*(tp);
            out.println(ans);
        }
}

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());
    }

}