#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, cnt = 0, fl = 0, num = 0;
  scanf("%d", &n);
  scanf("%d", &k);
  int par[n + 1];
  int i, j, m;
  for (i = 0; i < n; i++) par[i] = -1;
  for (i = 0; i < k; i++) {
    fl = 0;
    scanf("%d", &m);
    int b[m + 1];
    for (j = 0; j < m; j++) {
      scanf("%d", &b[j]);
    }
    int l = 0;
    if (b[0] == 1) {
      l++;
      while (b[l] == b[l - 1] + 1) l++;
      l--;
      fl = 1;
      num = l;
    }
    if (fl)
      cnt += m - l - 1;
    else
      cnt += m - 1;
  }
  n = n - num;
  cnt += n - 1;
  printf("%d ", cnt);
  printf("\n");
  return 0;
}
