#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<vector<long long> > b(k);
  for (long long i = 0; i < k; i++) {
    long long m;
    cin >> m;
    for (long long j = 0; j < m; j++) {
      long long t;
      cin >> t;
      a[t - 1] = i;
      b[i].push_back(t);
    }
  }
  long long c = 0;
  long long f = 0;
  for (long long i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      c++;
      f = 1;
    }
    if (f == 1 && a[i] == a[i - 1]) {
      c += 2;
    }
  }
  cout << c << endl;
  return 0;
}
