import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class Matryoshka {
	
	public static void main( String args[])
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		
		int n = in.nextInt(), k = in.nextInt();
		
		int a;
		int m;
		int l = 0;
		boolean flag = false;
		int[] tmp = null;
		
		for(int i = 0; i < k; ++i)
		{
			m = in.nextInt();
			
			for(int j = 0; j < m; ++j)
			{
				a = in.nextInt();
				
				if(a == 1)
				{
					flag = true;
					tmp = new int[m];
				}
				
				if(flag)
				{
					tmp[j] = a;
					
					if(tmp[0] == 1 && (tmp[j] - tmp[0]) == j)
					{	
						l++; 
					}
				}

			}
			
			flag = false;
		}
		
		System.out.println(2*n-2*l-k+1);

		
	}
	
	
	static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;

	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }

	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	}

}
