#include <bits/stdc++.h>
using namespace std;
vector<int> con[100010];
int main(void) {
  int n, m;
  cin >> n >> m;
  int totalsteps = 0;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x;
    for (int j = 0; j < x; ++j) {
      cin >> y;
      con[i].push_back(y);
    }
    totalsteps += (x - 1);
  }
  int rec = 0;
  for (int k = 0; k < m; ++k) {
    for (int i = 0; i < con[k].size() - 1; ++i) {
      if (!((con[k][i + 1] == con[k][i] + 1) && con[k][0] == 1)) {
        rec += 2;
      }
    }
  }
  totalsteps = m - 1;
  cout << totalsteps + (rec) << endl;
}
