import java.io.*;
import java.util.*;
public class matryoshka {
	private static int count = 0;
	private static Set<group> set = new HashSet<group>();
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int n = Integer.parseInt(st.nextToken());
		int num = Integer.parseInt(st.nextToken());
		
		for(int k = 0; k < num; k++) {
			makeGroups(f.readLine());
		}
		System.out.println(count + set.size() - 1);
	}
	
	private static void makeGroups(String s) {
		StringTokenizer st = new StringTokenizer(s);
		int num = Integer.parseInt(st.nextToken());
		ArrayList<group> g = new ArrayList<group>();
		int index = 0;
		for(int k = 0; k < num; k++) {
			int temp = Integer.parseInt(st.nextToken());
			if(g.size() == 0) {
				g.add(new group(temp, temp));
			} else if(g.get(index).canAdd(temp)) {
				g.get(index).add(temp);
			} else {
				set.add(g.get(index));
				g.add(new group(temp, temp));
				index++;
				count++;
			}
			set.add(g.get(index));
		}
		
	}
	
	private static class group {
		private int start;
		private int end;
		
		public group(int s, int e) {
			start = s;
			end = e;
		}
		public boolean canAdd(int i) {
			return i == end + 1;
		}
		
		public void add(int i) {
			end = i;
		}
		
	}
}