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


public class Main {

	static IO io;
	static int n,k;
	static long mod = 1000000007L;
	static Stack<Integer> stack;
	
	public static void main(String args[]) throws Exception{
	
		io = new IO();
		io.init();
		stack = new Stack<Integer>();
		//----------------------------------------
		n = io.nextInt();
		k = io.nextInt();
		
		int[][] chains = new int[k][];
		
		long ans  = k-1;
		
		for( int i = 0 ; i < k ; ++i ){
			int size = io.nextInt();
			chains[i] = new int[size];
			
			for( int j = 0 ; j < size ; ++j )
				chains[i][j] = io.nextInt();
			
			boolean locha = false;
			
			for( int j = 1 ; j < size ; ++j ){
				if( (chains[i][j-1] + 1   == chains[i][j])  && !locha ) ;
				else {
					ans += 2;
					locha = true;
				}
			}
		}
		
		io.println( ans );
		//----------------------------------------
		io.destroy();
	}
	
	static long pow( long base , long exp){	//with mod
		
		if( exp == 0 ) return 1;
		
		long temp = pow( base,exp/2);
		temp =(temp*temp);
		
		if( exp%2 == 0 ) 
			return temp;
		else
			return (temp*base);
	}

	static long ncr ( int n , int r ){ // with mod
		
		long num = 1;
		long den = 1;
		
		for( int i = n ; i >= n -r+1 ; --i )
			num = (num*i)%mod;
		
		for( int i = 1 ; i <= r ; ++i )
			den = (den*i)%mod;
		
		return  (num*pow(den,mod-2))%mod;
	}
	
	static long gcd(long a, long b){
		if( a == 0 ) return b;
		if( b == 0 ) return a;
		if( a > b) return gcd(a%b,b);
		else return gcd(a,b%a);
	}
	
	static long pow_with_mod( long base , long exp){	//with mod
		
		if( exp == 0 ) return 1;
		
		long temp = pow_with_mod( base,exp/2);
		temp =(temp*temp)%mod;
		
		if( exp%2 == 0 ) 
			return temp;
		else
			return (temp*base)%mod;
	}
	
	static class IO{
		
		
		BufferedReader reader;
		StringTokenizer tokenizer;
		PrintWriter writer;

		public void init() {
			try {
				reader = new BufferedReader(new InputStreamReader(System.in),8*1024);
				writer = new PrintWriter(System.out);
			} catch (Exception e) {
				e.printStackTrace();
				System.exit(261);
			}
		}

		void destroy() {
			writer.close();
			System.exit(0);
		}

		void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		void println(Object... objects) {
			print(objects);
			writer.println();
		}

		String nextLine() throws IOException {
			return reader.readLine();
		}

		String nextToken() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(nextLine());
			return tokenizer.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextToken());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(nextToken());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(nextToken());
		}
	}
}
