#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100010], i, k, j, m, countt = 0, n;
  cin >> n >> k;
  for (i = 0; i < k; i++) {
    cin >> m;
    for (j = 0; j < m; j++) {
      cin >> a[j];
    }
    if (a[0] == 1) {
      for (j = 0; j + 1 < m && a[j] + 1 == a[j + 1]; j++)
        ;
      countt += m - 1 - j;
    } else
      countt += (m - 1);
  }
  cout << 2 * countt + k - 1;
  return 0;
}
