import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
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 caseOfMatryoshkas {

    static int valid=1;
    static boolean validChain(int[] chain)
    {
        int len=chain.length;
        int curr=1;
        if(chain[0]!=1)
            return false;
        for(int i=1;i<len;i++)
            if(chain[i]!=chain[i-1]+1)
                break;
            else
                curr++;
            valid=curr;
        return true;
    }
    public static void main(String[] args) throws IOException {
        InputReader rd=new InputReader(System.in);
        int matryoshkas=rd.nextInt();
        int chains=rd.nextInt();
        ArrayList<int[]> matChains=new ArrayList<int[]>();
        int len;
        for(int i=0;i<chains;i++)
        {
            len=rd.nextInt();
            int[] chain=new int[len];
            for(int j=0;j<len;j++)
                chain[j]=rd.nextInt();
            matChains.add(chain);
        }
        int res=0;
        for(int[] chain : matChains)
        {
            //System.out.println(res);
            validChain(chain);
            if(!validChain(chain))
                res+=chain.length-1;
            else
                res+=chain.length-valid;
            
        }
        System.out.println(res+matryoshkas-valid);
    }
    
}

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());
    }
}