#include <bits/stdc++.h>
using namespace std;
map<int, int> used;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<pair<int, int> > v;
  vector<int> p[100001];
  for (int i = 0; i < k; i++) {
    int a;
    scanf("%d", &a);
    for (int j = 0; j < a; j++) {
      int r;
      scanf("%d", &r);
      v.push_back(make_pair(r, i));
      p[i].push_back(r);
    }
  }
  sort(v.begin(), v.end());
  int ans = 0;
  int rr = 1e9, dd = 0;
  for (int i = 1; i < v.size(); i++) {
    if (v[i - 1].second != v[i].second) {
      rr = min(rr, v[i - 1].first);
      used[v[i - 1].first]++;
      used[v[i].first]++;
    }
    if (!used[v[i].first]) {
      dd = max(dd, v[i].first);
    }
  }
  if ((n - rr) > 0) ans += (n - rr);
  for (int i = 0; i < k; i++) {
    int mn = 1e9, mx = 0;
    int cnt = 0;
    bool contain = false;
    for (int j = 0; j < p[i].size(); j++) {
      if (p[i][j] > rr) {
        cnt++;
      }
      if (p[i][j] <= rr) contain = true;
    }
    if (contain) {
      ans += cnt;
    } else {
      if ((cnt - 1) > 0) ans += cnt - 1;
    }
  }
  printf("%d", ans);
  return 0;
}
