#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 100;
int a[maxn];
int n, k;
int main() {
  int num;
  while (~scanf("%d%d", &n, &k)) {
    int cha = 0;
    int cc = 0;
    for (int i = 0; i < k; ++i) {
      int flag = 1, x = 0;
      scanf("%d", &num);
      for (int i = 1; i <= num; ++i) scanf("%d", &a[i]);
      for (int i = 1; i < num; i++) {
        if (a[i] != a[i + 1] - 1) {
          x++;
          flag = 0;
        }
      }
      if (!flag)
        cc += x + 1;
      else
        cc++;
      cha += x;
    }
    printf("%d\n", cha + cc - 1);
  }
}
