#include <bits/stdc++.h>
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  int ret = N - 1;
  int max = 0;
  int part = 0;
  for (int i = 0; i < K; i++) {
    int M;
    scanf("%d", &M);
    int a[100001];
    if (M == 1) {
      scanf("%d", &a[0]);
      continue;
    }
    part += M - 1;
    for (int j = 0; j < M; j++) scanf("%d", &a[j]);
    int tok = 0;
    for (int j = 0; j < M; j++) {
      if (a[j] == 1) {
        for (int k = j + 1; k < M; k++) {
          if (a[k - 1] + 1 == a[k]) {
            tok++;
          } else
            break;
        }
        break;
      } else {
        break;
      }
    }
    max = max < tok ? tok : max;
  }
  printf("%d", ret + part - max * 2);
  return 0;
}
