#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
typedef struct node {
  int pre, next;
  node() { pre = next = -1; }
};
int n, k;
node p[maxn];
int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; ++i) {
    int t;
    scanf("%d", &t);
    int pre = -1;
    for (int j = 0; j < t; ++j) {
      int v;
      scanf("%d", &v);
      p[v].pre = pre;
      if (pre != -1) p[pre].next = v;
      pre = v;
    }
  }
  int ans = 0;
  for (int i = 2; i <= n; ++i) {
    if (p[i - 1].next == i) continue;
    if (p[i - 1].next != -1) {
      ans++;
      p[p[i - 1].next].pre = -1;
    }
    if (p[i].pre != -1) {
      ans++;
      p[p[i].pre].next = -1;
      p[i].pre = -1;
    }
    if (p[i].next != -1) {
      ans++;
      p[p[i].next].pre = -1;
      p[i].next = -1;
    }
    p[i].pre = i - 1;
    p[i - 1].next = i;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
