
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

/*
public class _556C {

}

 */

public class _556C {
	public void solve() throws FileNotFoundException {
		InputStream inputStream = System.in;

		InputHelper inputHelper = new InputHelper(inputStream);

		PrintStream out = System.out;

		//actual solution
		
		int n = inputHelper.readInteger();
		int k = inputHelper.readInteger();
		
		int ans = 0;
		for(int i = 0; i < k; i++)
		{
			int m = inputHelper.readInteger();
			
			ans += (m - 1);
			
			List<Integer> al = new ArrayList<Integer>();
			
			for(int j = 0; j < m; j++)
			{
				int a = inputHelper.readInteger();
				
				al.add(a);
			}
			
			if(al.get(0) == 1)
			{
				for(int j = 1; j < al.size(); j++)
				{
					if(al.get(j) == al.get(j - 1) + 1)
					{
						ans -= 2;
					}
					else
					{
						break;
					}
				}
			}
		}
		
		ans += (n - 1);
		
		System.out.println(ans);

		//end here
	}

	public static void main(String[] args) throws FileNotFoundException {
		(new _556C()).solve();
	}

	class InputHelper {
		StringTokenizer tokenizer = null;
		private BufferedReader bufferedReader;

		public InputHelper(InputStream inputStream) {
			InputStreamReader inputStreamReader = new InputStreamReader(
					inputStream);
			bufferedReader = new BufferedReader(inputStreamReader, 16384);
		}

		public String read() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = bufferedReader.readLine();
					if (line == null) {
						return null;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

			return tokenizer.nextToken();
		}

		public Integer readInteger() {
			return Integer.parseInt(read());
		}

		public Long readLong() {
			return Long.parseLong(read());
		}
	}
}