import java.io.IOException;
import java.util.HashMap;
import java.util.Scanner;

public class C556 {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int result = 0;
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        int[] arr = new int[k];
        int index = 0;
        for (int i = 0; i < k; i++) {
            int temp = in.nextInt();
            arr[i] = temp;
            for (int j = 0; j < temp; j++) {
                int a = in.nextInt();
                if (a == 1)
                    index = i;
                map.put(a, i);
            }
        }
        /*int previous = map.get(1);
        for (int i = 2; i <= n; i++) {
            if (map.get(i) == previous) result--;
            else {
                previous = map.get(i);
                result++;
            }
        }*/
        int i;
        int j = 1;
        for (i = 2; i <= n; i++) {
            if (map.get(i) == index) {
                j++;
            }
            else break;
        }
        for (i = 0; i < k; i++) {
            if (i != index) {
                result = result + 2*(arr[i] - 1)  + 1;
            } else {
                result += 2*(arr[index] - j);
            }
        }
        System.out.println(result);
    }
}