#include <bits/stdc++.h>
using namespace std;
int main() {
  int size, chains;
  scanf("%d%d", &size, &chains);
  vector<vector<int> > mat(chains);
  for (int i = (0); i < (chains); i++) {
    int chainsize;
    scanf("%d", &chainsize);
    vector<int> aux(chainsize);
    for (int i = (0); i < (chainsize); i++) {
      scanf("%d", &aux[i]);
    }
    mat[i] = aux;
  }
  int i = 0;
  while (mat[i][0] != 1) {
    i++;
  }
  int conn = 0, curr = 2;
  int j = 1;
  while (j < mat[i].size() && curr == mat[i][j]) {
    conn++;
    curr++;
    j++;
  }
  int total = (mat[i].size() - 1 - conn);
  for (int k = 0; k < mat.size(); k++) {
    if (k != i) {
      total += mat[k].size() - 1;
    }
  }
  total += (size - 1 - conn);
  printf("%d\n", total);
  return 0;
}
