#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
int n, m, a[N];
int work() {
  int ret = 0;
  for (int i = 1; i <= m; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &a[j]);
    }
    int cnt = 0;
    for (int j = 1; j < k; j++)
      if (a[j] != a[j - 1] + 1) {
        cnt++;
      }
    ret += cnt;
    ret += cnt + 1;
  }
  return ret - 1;
}
int main() {
  scanf("%d%d", &n, &m);
  printf("%d\n", work());
  return 0;
}
