#include <bits/stdc++.h>
using namespace std;
int n, k, m[100005], a[100005][100], v[100005], ans = 0;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &m[i]);
    for (int j = 1; j <= m[i]; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j < m[i]; j++) {
      if (a[i][j + 1] != a[i][j] + 1) {
        v[i] = m[i] - j;
        break;
      }
    }
    ans += 2 * v[i];
  }
  ans += k - 1;
  printf("%d\n", ans);
  return 0;
}
