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