#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, l, i, j, index, found = 0;
  cin >> n >> k;
  int time = n - 1;
  for (i = 0; i < k; i++) {
    found = 0;
    cin >> l;
    time += l - 1;
    int b[l];
    for (j = 0; j < l; j++) {
      cin >> b[j];
      if (b[j] == 1) {
        index = j;
        found = 1;
      }
    }
    if (found) {
      while (index < l - 1) {
        if (b[index + 1] == b[index] + 1) {
          time -= 2;
          index++;
        } else
          break;
      }
    }
  }
  cout << time;
  return 0;
}
