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


public class Main {

    static Pair arr[];
    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        
        int n = Reader.nextInt(),  k = Reader.nextInt();
        int count = 0;
        for(int i = 0; i < k; i++){
            int x = Reader.nextInt();
            int y = Reader.nextInt();
            
            for(int j = 1; j < x; j++){
                int temp = Reader.nextInt();
                if(temp != y+1)
                    count++;
                y = temp;
            }
        }
        
        System.out.println((k+count-1)+count);
    }
   
}

class Pair implements Comparable<Pair>{

    int len;
    int cost;
    
    Pair(int a){
        len = a;
    }
    
    @Override
    public int compareTo(Pair t) {
        return len - t.len;
    }
    
}


class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}
    
