#include <bits/stdc++.h>
using namespace std;
long long a[100009];
int main() {
  long long n, k, m, vps = 0, ind = 0, parti = 0;
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    cin >> m;
    for (int j = 0; j < m; ++j) {
      cin >> a[j];
    }
    ind = 0;
    if (a[0] == 1) {
      for (int j = 1; j < m; ++j) {
        if (a[j] == (a[j - 1] + 1)) {
          ind++;
        } else
          break;
      }
    }
    vps += max(0LL, m - ind - 1);
    parti += max(0LL, m - ind - 1) + 1;
  }
  cout << vps + parti - 1;
  return 0;
}
