#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a, sec, count, assem;
  long long b[100000], elem[100000], disassem[100000];
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    count = 0;
    sec = 0;
    cin >> a;
    for (int j = 0; j < a; j++) {
      cin >> b[j];
    }
    if (b[0] == 1) {
      for (int x = 0; x < a - 1; x++) {
        if (b[x + 1] == b[x] + 1)
          count++;
        else
          break;
      }
    }
    disassem[i] = a - count - 1;
    elem[i] = a - count;
  }
  int sum = 0, td = 0, te = 0;
  for (int i = 0; i < k; i++) td = td + disassem[i];
  for (int i = 0; i < k; i++) te = te + elem[i];
  sum = td + te - 1;
  cout << sum;
}
