#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 6;
const double eps = 1e-8;
int n, k, a[N], m;
int main() {
  scanf("%d%d", &n, &k);
  int ans = k - 1, ans1 = 0;
  for (int i = 1; i <= k; i++) {
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
    if (a[1] != 1) {
      ans1 += m - 1;
      ans += m - 1;
      continue;
    }
    for (int i = 1; i < m; i++)
      if (a[i] != a[i + 1] - 1) {
        ans1 += m - i;
        ans += m - i;
        break;
      }
  }
  printf("%d\n", ans1 + ans);
}
