#include <bits/stdc++.h>
using namespace std;
int n, e, a[100100], k, sol, lp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> e;
  sol = n - 1;
  while (e--) {
    cin >> k;
    for (int i = 1; i <= k; ++i) cin >> a[i];
    lp = 1;
    for (int i = 2; i <= k; ++i) {
      while (a[1] == 1 && a[i] == a[i - 1] + 1 && i <= k) i++;
      sol += (k - (i - 1)) - (i - 2);
      break;
    }
  }
  cout << sol;
  return 0;
}
