#include <bits/stdc++.h>
using namespace std;
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
int main() {
  int n = read(), k = read(), m;
  int a[100005], i;
  unsigned long long ans = 0;
  vector<int> en;
  while (k--) {
    m = read();
    for (i = 0; i < m; i++) a[i] = read();
    for (i = 0; i < m; ++i) {
      while (i < m - 1 && a[i] + 1 == a[i + 1]) i++;
      if (i != m - 1) ans++;
      en.push_back(a[i]);
    }
  }
  ans += unsigned long long(en.size()) - 1LL;
  printf("%I64d", ans);
  return 0;
}
