#include <bits/stdc++.h>
using namespace std;
int old, ne, res, rr, cur;
int n, k, m;
vector<int> d[100005];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cin >> m;
    cin >> old;
    d[cur].push_back(old);
    for (int j = 2; j <= m; j++) {
      cin >> ne;
      if ((ne - 1) != old) ++cur;
      d[cur].push_back(ne);
      old = ne;
    }
    ++cur;
  }
  sort(d, d + cur - 1);
  for (int i = 1; i < cur; i++) {
    res += d[i].size() - 1;
    ++res;
    res += d[i].size() - 1;
  }
  cout << res;
}
