#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v[k];
  int lines[k];
  for (int i = 0; i < k; i++) {
    cin >> lines[i];
    for (int j = 0; j < lines[i]; j++) {
      int x;
      cin >> x;
      v[i].push_back(x);
    }
  }
  int ans = 0;
  for (int i = 0; i < k; i++) {
    if (v[i][0] != 1)
      ans += lines[i] - 1;
    else {
      for (int j = 1; j < lines[i]; j++) {
        if (v[i][j] != v[i][j - 1] + 1) {
          ans += lines[i] - j;
          break;
        }
      }
    }
  }
  ans += ans + k - 1;
  cout << ans << endl;
  return 0;
}
