import java.io.*;

public class C310_1_C {
    public static void main(String []args) throws IOException {
        new Solution().solve();
    }
}

class Solution {
    FastReader fr = new FastReader();
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

    public void solve() throws IOException {
        int n = fr.nextInt();
        int k = fr.nextInt();
        int res = 0;

        for (int i = 0; i < k; i++) {
            int r = fr.nextInt();
            int expect = 1;
            for (int j = 0; j < r; j++) {
                int d = fr.nextInt();
                if (expect == d) {
                    expect++;
                }
            }

            if (expect > 1) {
                res += r - (expect - 1);
                res += r - (expect - 1);
            } else {
                res += r - 1;
                res += r;
            }
        }
        System.out.println(res);
    }
}

class FastReader {
    private InputStream is;
    private int bufferSize = 1 << 17;
    private byte []buffer = new byte[bufferSize];
    private int currentIndex = 0;
    private int lastIndex = 0;

    public FastReader() {
        is = new BufferedInputStream(System.in);
//      try {
//          is = new BufferedInputStream(new FileInputStream(new File("test.txt")));
//      } catch (FileNotFoundException e) {
//          e.printStackTrace();
//      }
    }

    public int nextInt() {
        int result = 0;
        int minus = 1;

        byte character = readNext();

        while (character == ' ' || character == '\n' || character == '\r') {
            character = readNext();
        }

        if (character == '-') {
            minus = -1;
            character = readNext();
        }

        while (character != ' ' && character != '\n' && character != '\r') {
            result = result * 10 + (character - '0');
            character = readNext();
        }

        return minus*result;
    }

    public long nextLong() {
        long result = 0;
        int minus = 1;

        byte character = readNext();

        while (character == ' ' || character == '\n' || character == '\r') {
            character = readNext();
        }

        if (character == '-') {
            minus = -1;
            character = readNext();
        }

        while (character != ' ' && character != '\n' && character != '\r') {
            result = result * 10 + (character - '0');
            character = readNext();
        }

        return minus*result;
    }

    public String nextString() {
        StringBuffer result = new StringBuffer();

        byte character = readNext();

        while (character == ' ' || character == '\n' || character == '\r') {
            character = readNext();
        }

        while (character != ' ' && character != '\n' && character != '\r') {
            result.append((char)character);
            character = readNext();
        }

        return result.toString();
    }

    public String nextLine() {
        StringBuffer result = new StringBuffer();

        byte character = readNext();

        while (character == '\n' || character == '\r') {
            character = readNext();
        }

        while (character != '\n' && character != '\r') {
            result.append((char)character);
            character = readNext();
        }

        return result.toString();
    }

    private byte readNext() {
        if (currentIndex == lastIndex) {
            try {
                lastIndex = is.read(buffer, 0, bufferSize);
            } catch (IOException e) {
                throw new RuntimeException("What?");
            }
            if (lastIndex == -1) {
                buffer[0] = -1;
            }
            currentIndex = 0;
        }

        return buffer[currentIndex++];
    }
}