#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, ans = 0;
  cin >> n >> k;
  int o = 1;
  for (int i = 0; i < k; i++) {
    vector<int> v;
    int m, x;
    cin >> m;
    for (int p = 0; p < m; p++) {
      cin >> x;
      v.push_back(x);
    }
    if (v[0] == 1) {
      int c = v.size();
      for (int u = 0; u < v.size(); u++) {
        if (v[u] != u + 1) {
          c = u;
          break;
        }
      }
      o = v[c - 1];
      ans = ans + m - c;
    } else {
      ans = ans + m - 1;
    }
  }
  ans = ans + n - o;
  cout << ans << "\n";
}
