#include <bits/stdc++.h>
using namespace std;
vector<int> a[100114];
int f[100114];
int find_set(int x) { return f[x] == x ? f[x] : f[x] = find_set(f[x]); }
int main() {
  int n, k, m;
  scanf("%d%d", &n, &k);
  for (int i = 0; i <= n; i++) {
    f[i] = i;
  }
  int x, y, p;
  for (int i = 0; i < k; i++) {
    scanf("%d", &m);
    for (int j = 0; j < m; j++) {
      scanf("%d", &x);
      if (x == 1) p = i;
      a[i].push_back(x);
    }
  }
  int cnt = 0;
  for (int j = 1; j < a[p].size(); j++) {
    if (a[p][j] != a[p][j - 1] + 1) {
      cnt += a[p].size() - j;
      break;
    } else {
      x = find_set(a[p][j]);
      y = find_set(a[p][j - 1]);
      f[x] = y;
    }
  }
  for (int i = 0; i < k; i++) {
    if (i == p) continue;
    cnt += a[i].size() - 1;
  }
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    if (f[i - 1] != f[i]) {
      ans++;
    }
  }
  printf("%d\n", ans + cnt);
  return 0;
}
