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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Ivan
 */
public class matryoshkas {

    static boolean isValid(int[] chain)
    {
        int length=chain.length;
        if(length==1)
            if(chain[0]==1)
                return true;
            else
                return false;
        for(int i=0;i<length-1;i++)
            if(chain[i]+1!=chain[i+1])
                return false;
        return true;
    }
    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        int matryoshkas=Reader.nextInt();
        int chains=Reader.nextInt();
        int solution=0;
        int validLength=1;
        for(int i=0;i<chains;i++)
        {
            int length=Reader.nextInt();
            int[] chain=new int[length];
            for(int j=0;j<length;j++)
                chain[j]=Reader.nextInt();
            if(!isValid(chain))
                solution+=length-1;
            else
                validLength=length;
            
            //System.out.println(solution+" "+length);
        }
        //System.out.println(solution);
        solution+=matryoshkas-validLength;
        
        System.out.println(solution);
    }
    
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}