#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long n, k, m, x;
  cin >> n >> k;
  long long counter = n - 1, counterbreak = 0;
  long long last = 0;
  for (int i = 0; i < k; i++) {
    cin >> m;
    for (int h = 0; h < m; h++) {
      cin >> x;
      if (x == 1 && last == 0) {
        last = x;
        continue;
      }
      if (last != -1 && last != 0 && last + 1 == x) {
        last = x;
        counter--;
      } else if (h != 0) {
        counterbreak++;
      }
    }
    if (last) last = -1;
  }
  cout << counter + counterbreak << endl;
  return 0;
}
