#include <bits/stdc++.h>
using namespace std;
vector<int> v[100009];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    int tn;
    scanf("%d", &tn);
    for (int j = 1; j <= tn; j++) {
      int tem;
      scanf("%d", &tem);
      v[i].push_back(tem);
    }
  }
  int ct = 0;
  int time = 0;
  int f = 0;
  int now;
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (v[i][j] == 1) {
        f = 1;
        now = 1;
        ct++;
        if (j != 0) time++;
        continue;
      }
      if (f == 1 && v[i][j] == now + 1) {
        now++;
        continue;
      }
      f = 0;
      ct++;
      if (j != 0) time++;
    }
    f = 0;
  }
  cout << time + ct - 1 << endl;
}
