#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int re = 0;
  vector<int> a[101010];
  int ss = k;
  for (int i = 0; i < k; i++) {
    int m;
    cin >> m;
    a[i] = vector<int>(m);
    for (int j = 0; j < m; j++) cin >> a[i][j];
    bool ok = true;
    int lis = m - 1;
    for (int j = 0; j < m - 1; j++) {
      if (ok && a[i][j] == a[i][j + 1] - 1) {
        lis--;
      } else {
        ok = false;
        re++;
      }
    }
    ss += lis;
  }
  cout << re + ss - 1 << endl;
  return 0;
}
