#include <bits/stdc++.h>
using namespace std;
vector<int> v[100100];
int n, k, m, i, j, x, w;
int ans, comp;
int main() {
  scanf("%d%d", &n, &k);
  ans = 0;
  comp = 0;
  for (i = 1; i <= k; i++) {
    scanf("%d", &m);
    for (j = 1; j <= m; j++) {
      scanf("%d", &x);
      v[i].push_back(x);
    }
    if (v[i][0] == 1) {
      for (j = 1; j < v[i].size(); j++)
        if (v[i][j - 1] != v[i][j] - 1) break;
      j--;
      comp++;
      comp += (v[i].size() - 1 - j);
      ans += (v[i].size() - 1 - j);
    } else {
      comp += (v[i].size());
      ans += (v[i].size() - 1);
    }
  }
  ans += (comp - 1);
  printf("%d", ans);
  return 0;
}
