#include <bits/stdc++.h>
int a[100005];
int main() {
  int n, k, m, parts, flag, i, count, z;
  scanf("%d %d", &n, &k);
  parts = 0;
  z = 0;
  while (k--) {
    scanf("%d", &m);
    flag = 0;
    count = 1;
    scanf("%d", &a[0]);
    if (a[0] == 1) {
      for (i = 1; i < m; i++) {
        scanf("%d", &a[i]);
        if (flag == 0) {
          if ((a[i] - a[i - 1]) != 1)
            flag = 1;
          else
            count++;
        }
      }
      z = z + m - count;
      parts = parts + m - count + 1;
    } else {
      for (i = 1; i < m; i++) {
        scanf("%d", &a[i]);
      }
      z = z + m - 1;
      parts = parts + m;
    }
  }
  parts--;
  printf("%d\n", parts + z);
  return 0;
}
