#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<pair<int, int> > v;
int main() {
  int n, k, m, x;
  cin >> n >> k;
  int z = -1;
  long long count = 0, sel = 1;
  g.resize(k + 1);
  for (int i = 0; i < k; ++i) {
    cin >> m;
    for (int j = 0; j < m; j++) {
      cin >> x;
      g[i].push_back(x);
      if (x == 1) z = i;
    }
  }
  for (int i = 1; i < g[z].size(); i++) {
    if (g[z][i] - 1 == g[z][i - 1])
      sel++;
    else {
      count = g[z].size() - sel;
      break;
    }
  }
  for (int i = 0; i < k; ++i) {
    if (i == z) continue;
    for (int j = 1; j < g[i].size(); j++) {
      count++;
    }
  }
  count += (n - sel);
  cout << count << endl;
}
