import java.io.*;

public class Case_of_Matryoshkas {

	public static void main(String[] args) throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String[] s = br.readLine().split(" ");
		int n = Integer.parseInt(s[0]);
		int k = Integer.parseInt(s[1]);
		int len = 0;
		long ans = 0;
		for(int i = 0; i < k; i++)
		{
			s = br.readLine().split(" ");
			int x = Integer.parseInt(s[0]);
			ans  += x-1;
			if(Integer.parseInt(s[1]) == 1)
			{
				for(int j = 1; j < x; j++)
				{
					if(Integer.parseInt(s[j+1]) == Integer.parseInt(s[j]) + 1) len++;
					else break;
				}
			}
		}
		System.out.println(ans - len + n - len - 1);
			
	}
}