#include <bits/stdc++.h>
using namespace std;
int main() {
  int tb[100001] = {0};
  int t[100000];
  int tn = 0;
  int n, k;
  int a;
  int first;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> a;
    cin >> first;
    t[tn] = first;
    tn++;
    for (int j = 1; j < a; j++) {
      cin >> t[tn];
      tb[t[tn]] = first;
      first = t[tn];
      tn++;
    }
  }
  sort(t, t + tn);
  int re = 0;
  for (int i = tn - 1; i > 0; i--) {
    if (tb[t[i]] != t[i - 1]) {
      re++;
      if (tb[t[i]] != 0) re++;
    }
  }
  cout << re;
  return 0;
}
