#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, chain, in1, in2, tcontinue, tuncontinue, flag;
  while (cin >> n >> k) {
    tuncontinue = 0;
    tcontinue = 0;
    for (int tmp = 0; tmp < k; tmp++) {
      in2 = 0;
      in1 = 0;
      flag = 0;
      cin >> chain;
      tuncontinue += chain - 1;
      cin >> in1;
      if (in1 == 1)
        for (int tmp = 1; tmp < chain; tmp++) {
          cin >> in2;
          if (flag == 0 && in2 - in1 == 1)
            tcontinue++;
          else
            flag = 1;
          in1 = in2;
        }
      else {
        for (int tmp = 1; tmp < chain; tmp++) cin >> in2;
      }
    }
    cout << n - 1 - tcontinue * 2 + tuncontinue << endl;
  }
  return 0;
}
