#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ctr = 0, ctr1 = 0, ainvayi;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int count, initial = -1, init = 0;
    cin >> count;
    for (int j = 0; j < count; j++) {
      int temp;
      cin >> temp;
      if (initial == -1) initial = temp;
      if (initial == 1) {
        if (temp - init == 1) {
          ctr++;
          init++;
        } else
          ctr1++;
      } else
        ctr1++;
    }
  }
  ctr1 -= m - 1;
  cout << ctr1 + n - ctr << endl;
  return 0;
}
