#include <bits/stdc++.h>
using namespace std;
int a[110000];
int main() {
  int n, k, cnt1 = 0, cnt2 = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; i++) scanf("%d", &a[i]);
    int l = 1;
    if (a[0] == 1) {
      for (int i = 0; i < m - 1; i++) {
        if (a[i + 1] - a[i] > 1) {
          break;
        }
        l++;
      }
    }
    cnt1 += m - l;
    cnt2 += m - l + 1;
  }
  cout << cnt1 + cnt2 - 1 << endl;
  return 0;
}
