#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 k = 1;
    for (int i = 1; i < m; i++) {
      if (a[i] - a[i - 1] > 1) {
        cnt1++;
        k++;
      }
    }
    cnt2 += k;
  }
  cout << cnt1 + cnt2 - 1 << endl;
  return 0;
}
