#include <bits/stdc++.h>
using namespace std;
int N, K, M, Sol = 0, T[100000];
int main() {
  cin >> N >> K;
  int Nr = N - 1;
  while (K--) {
    cin >> M;
    Sol += M - 1;
    cin >> T[1];
    if (M == 1) Nr--;
    int X = 0;
    for (int j = 2; j <= M; j++) {
      cin >> T[j];
      if (T[j] - 1 == T[j - 1]) {
        X++;
        Nr--;
      } else {
        Sol -= X;
        X = 0;
      }
      if (j == M && T[j] - 1 == T[j]) Sol -= X;
    }
  }
  cout << Nr + Sol;
  return 0;
}
