#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int ans = 0, res = 0;
  for (int i = 1; i <= k; i++) {
    int m;
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
    int cnt = 0;
    for (int i = 1; i <= m; i++) {
      int st = i;
      while (st <= m && a[st + 1] == a[st] + 1) st++;
      i = st;
      cnt++;
    }
    res += cnt;
    ans += cnt - 1;
  }
  ans += res - 1;
  printf("%d\n", ans);
  return 0;
}
