#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n = 0, k = 0;
  int man = 0;
  int h = 0, i = 0, b = 1;
  scanf("%d %d", &n, &k);
  for (int x = 1; x <= k; x++) {
    scanf("%d", &h);
    man += h;
    for (int y = 1; y <= h; y++) {
      scanf("%d", &i);
      if (i == y && i >= 2) b = y;
    }
  }
  printf("%d", man - k + n - 1 - 2 * (b - 1));
  return 0;
  return 0;
}
