#include <bits/stdc++.h>
using namespace std;
int n, k, groups, m, temp[100003], last, size_1, cut;
int main(void) {
  cin >> n >> k;
  groups = size_1 = cut = 0;
  for (int x = 1; x <= k; x++) {
    cin >> m;
    for (int i = 1; i <= m; i++) cin >> temp[i];
    groups++;
    temp[0] = temp[1];
    for (int i = 1; i <= m; i++) {
      if (temp[i] - temp[i - 1] > 1) groups++, cut++;
      if (temp[i] == 1) {
        int ptr = i;
        size_1 = 1;
        while (ptr <= n && temp[ptr] == size_1) ptr++, size_1++;
      }
    }
  }
  size_1--;
  cout << 2 * (n - size_1) - (groups - 1) + cut << endl;
}
