#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000")
using namespace std;
const int maxn = 100005;
int vis[maxn];
int main() {
  int n, m;
  int k, a, b;
  while (~scanf("%d%d", &n, &m)) {
    int cnt = 0;
    memset(vis, 0, sizeof(vis));
    int i, j;
    cnt += n - 1;
    for (i = 0; i < m; i++) {
      scanf("%d", &k);
      cnt += k - 1;
      for (j = 0; j < k; j++) scanf("%d", &vis[j]);
      if (vis[0] == 1) {
        int cur = 1;
        while (cur <= k) {
          if (vis[cur - 1] + 1 == vis[cur])
            cur++;
          else
            break;
        }
        cnt -= 2 * cur - 2;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
