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