#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<vector<long long> > dolls(k);
  for (long long i = 0; i < k; ++i) {
    long long m;
    cin >> m;
    dolls[i] = vector<long long>(m);
    for (long long j = 0; j < m; ++j) {
      cin >> dolls[i][j];
    }
  }
  long long pieces = k;
  long long moves = 0;
  for (long long i = 0; i < k; ++i) {
    bool keep = false;
    if (dolls[i][0] == 1) {
      keep = true;
    }
    for (long long j = 1; j < dolls[i].size(); ++j) {
      if (dolls[i][j] - dolls[i][j - 1] > 1 || !keep) {
        ++moves;
        ++pieces;
        keep = false;
      }
    }
  }
  moves += pieces - 1;
  cout << moves << endl;
  return 0;
}
