#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 100;
vector<int> v[maxn];
int n, k, b[maxn];
int main() {
  int num, x;
  while (~scanf("%d%d", &n, &k)) {
    int cha = 0;
    int cc = 0;
    for (int i = 0; i < k; ++i) {
      int flag = 1, x = 0;
      scanf("%d", &num);
      for (int j = 1; j <= num; ++j) {
        scanf("%d", &x);
        v[i].push_back(x);
      }
    }
    int maxn = 0;
    for (int i = 0; i < k; i++) {
      int cnt = 0;
      for (int j = 0; j < v[i].size(); j++) b[cnt++] = v[i][j];
      for (int j = cnt - 1; j >= 0; j--)
        if (b[j] + 1 != b[j + 1]) cnt = j + 1;
      if (b[0] == 1) maxn = cnt;
    }
    printf("%d\n", (n - maxn) * 2 - k + 1);
  }
}
