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