#include <bits/stdc++.h>
using namespace std;
template <typename T>
class heap : public priority_queue<T, vector<T>, greater<T> > {};
int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<vector<int> > v;
  v.resize(k);
  int len = 0;
  for (int i = 0; i < k; ++i) {
    int x;
    scanf("%d", &x);
    for (int j = 0; j < x; ++j) {
      int y;
      scanf("%d", &y);
      v[i].push_back(y);
    }
    if (v[i][0] == 1) {
      for (int j = 1; j < v[i].size(); ++j) {
        if (v[i][j] - 1 != v[i][j - 1])
          break;
        else
          ++len;
      }
    }
  }
  printf("%d\n", 2 * n - k - 1 - 2 * len);
}
