//coderadi
import java.io.*;
import java.util.*;


public class B {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		Node[] ar = new Node[n+1];
		for(int i=0; i<n+1; i++)
			ar[i] = new Node(i);
		while(m-- > 0){
			int a = sc.nextInt();
			Node prev = null;
			for(int i=0; i<a; i++){
				int temp = sc.nextInt();
				if(i!=0){
					prev.next = ar[temp];
				}
				prev = ar[temp];
			}			
		}
		Node curr = ar[1];
		long ans = 0;
		int count = 1;
		while(count != n){
			if(curr.next == null){
				curr.next = ar[curr.val + 1];
				ans = ans + 1;
			}
			else if(curr.next.val != curr.val + 1){
				curr.next = ar[curr.val+1];
				ans = ans + 2;
			}
			else{
				curr = curr.next;
				count++;
			}
		}

		System.out.println(ans);
	}
}


class Node{
	int val; Node next;
	public Node(int val){
		this.val = val;
		next = null;
	}
}