#include <bits/stdc++.h>
using namespace std;
int way[100010];
int main() {
  int n, m, k, t, pre, now, ans;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &m);
    for (int j = 1; j <= m; j++) {
      scanf("%d", &t);
      if (j == 1) {
        pre = t;
        way[t] = -1;
      } else {
        way[pre] = t;
        pre = t;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (way[i] != i + 1) {
      now = i;
      break;
    }
  now--;
  ans = n - k - now + (n - 1 - now);
  printf("%d\n", ans);
}
