#include <bits/stdc++.h>
using namespace std;
int main() {
  int ndoll, nstack;
  cin >> ndoll >> nstack;
  vector<vector<int> > stacks;
  stacks.resize(nstack);
  int j = 0;
  for (int i = 0; i < nstack; i++) {
    int factor;
    cin >> factor;
    stacks[j].resize(factor);
    for (int k = 0; k < factor; k++) {
      cin >> stacks[j][k];
    }
    j++;
  }
  int onestack = 0, leni = 0, time = 0;
  for (int i = 0; i < nstack; i++) {
    if (stacks[i][0] == 1) {
      onestack = i;
      leni = 1;
      while (leni < stacks[i].size() &&
             stacks[i][leni] == stacks[i][leni - 1] + 1) {
        leni++;
      }
      time += stacks[i].size() - leni;
    }
  }
  for (int i = 0; i < nstack; i++) {
    if (i != onestack) {
      time += stacks[i].size() - 1;
    }
  }
  time += ndoll - leni;
  cout << time << endl;
}
