#include <bits/stdc++.h>
using namespace std;
const int maxn = 1111111;
int a[maxn];
int i, j, n, k, res, flag, ll;
int main() {
  scanf("%d %d", &n, &k);
  res = n - 1, flag = 0;
  for (i = 1; i <= k; i++) {
    scanf("%d", &ll);
    res += ll - 1;
    for (j = 1; j <= ll; j++) scanf("%d", &a[j]);
    if (a[1] == 1)
      for (j = 2; j <= ll; j++)
        if (a[j] - a[j - 1] == 1)
          flag += 2;
        else
          break;
  }
  printf("%d\n", res - flag);
  return 0;
}
