#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(); ++i) {
      if (con[k][i] == 1) {
        while (i + 1 < con[k].size() && con[k][i + 1] == con[k][i] + 1)
          rec++, i++;
        break;
      }
    }
  }
  totalsteps += (n - 1);
  cout << totalsteps - (2 * rec) << endl;
}
