import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	static BufferedReader in = new BufferedReader(new InputStreamReader(
			System.in));
	static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
			System.out));
	final static int MOD = 1000000007;

	public static void main(String[] args) throws Exception {

		// System.out.println(Arrays.deepToString(combi));
		long test = 1;

		// long test = strToLong(in.readLine().trim()); // if number of
		// test cases
		for (int i = 0; i < test; i++) {
			req();
		}
		out.flush();

		out.close();

	}

	public static void req() throws Exception {

		long arr[] = splits(in.readLine(), 2);
		long n = arr[0];
		long k = arr[1];
		long allWeHave = 0;
		long keep =0;
		long need = n-1;
		
		int m =0;
		while (k-- > 0) {
			
			arr = splits2(in.readLine());
			m = arr.length;
			allWeHave+=(m-1);
			//boolean group =false;
			for(int i =0;i<m;i++)
			{
				
				if(arr[i]==1)
				{
					int temp =i;
					while(i<m  && arr[i]==i-temp+1)
					{
						keep++;
						i++;
					}
					if(keep>0)
					keep--;
				}
				
			}
//			System.out.println(keep);
			
		}
		
		
		long ans = need - keep + (allWeHave-keep);
		
		out.write(ans+"\n");
	}

	// takes a string with spaces as input and produces an array of long of
	// length n
	// input should be valid
	// should know length of array beforehand
	static long[] splits(String s, int n) {

		long[] out = new long[n];
		int idx = 0;

		StringTokenizer ss = new StringTokenizer(s);
		while (ss.hasMoreTokens()) {
			out[idx] = strToLong(ss.nextToken());

			idx++;
		}

		return out;

	}
	
	static long[] splits2(String s) {

		long[] out;
		int idx = 0;

		StringTokenizer ss = new StringTokenizer(s);
		int n = strToInt(ss.nextToken());
		out = new long[n];
		while (ss.hasMoreTokens()) {
			out[idx] = strToLong(ss.nextToken());

			idx++;
		}

		return out;

	}

	// returns gcd of two long parameters
	// i think its algo by euclid :P
	static long gcd(long a, long b) {

		return b == 0 ? a : gcd(b, a % b);
	}

	// returns maximum among two long
	public static long max(long a, long b) {
		return a > b ? a : b;
	}

	// modulus of product of two long parameter
	public static long modPro(long a, long b) {
		// check value of MOD , may vary for different questions
		// or change the function to take mod as an input parameter :P
		return ((a % MOD) * (b % MOD)) % MOD;
	}

	public static long modInv(long a) {
		return new BigInteger(a + "").modPow(new BigInteger((MOD - 2) + ""),
				new BigInteger(MOD + "")).longValue();
	}

	// returns minimum among two long
	public static long min(long a, long b) {
		return a < b ? a : b;
	}

	// take a string as input and convert it to an integer
	// takes care of negatives
	// no commas or space expected in string
	// copied from codechef
	public static int strToInt(String str) {
		int i = 0;
		int num = 0;
		boolean isNeg = false;
		// Check for negative sign; if it's there, set the isNeg flag
		if (str.charAt(0) == '-') {
			isNeg = true;
			i = 1;
		}
		// Process each character of the string;
		while (i < str.length()) {
			num *= 10;
			num += str.charAt(i++) - '0'; // Minus the ASCII code of
											// '0' to get
			// the value of the charAt(i++).
		}
		if (isNeg)
			num = -num;
		return num;
	}

	// take a string as input and convert it to a long
	// takes care of negatives
	// no commas or space expected in string
	// copied from codechef
	public static long strToLong(String str) {
		int i = 0;
		long num = 0;
		boolean isNeg = false;
		// Check for negative sign; if it's there, set the isNeg flag
		if (str.charAt(0) == '-') {
			isNeg = true;
			i = 1;
		}
		// Process each character of the string;
		while (i < str.length()) {
			num *= 10;
			num += str.charAt(i++) - '0'; // Minus the ASCII code of
											// '0' to get
			// the value of the charAt(i++).
		}
		if (isNeg)
			num = -num;
		return num;
	}

}