#include <bits/stdc++.h>
using namespace std;
int N, K, M, a[100005], sep, ans;
vector<int> v;
vector<vector<int>> sets;
int main() {
  scanf("%d %d", &N, &K);
  for (int m = 0; m < (K); m++) {
    scanf("%d", &M);
    for (int i = 0; i < (M); i++) scanf("%d", &a[i]);
    bool d = 0;
    for (int i = 0; i < (M); i++) {
      v.push_back(a[i]);
      if (d) {
        sep++;
        sets.push_back(v);
        v.clear();
      }
      if (!d && i < M - 1 && a[i] != a[i + 1] - 1) {
        d = 1;
        sets.push_back(v);
        v.clear();
      }
    }
    if (!d) {
      sets.push_back(v);
      v.clear();
    }
  }
  sort(sets.begin(), sets.end());
  ans = sep;
  for (int i = 1; i < sets.size(); i++) {
    ans += (int)sets[i].size() - 1;
  }
  ans += N - sets[0].size();
  printf("%d\n", ans);
  return 0;
}
