#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int main() {
  int n, y, flag = 0, tt = 0, m, x;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &y);
    for (int j = 1; j <= y; j++) {
      scanf("%d", &x);
      graph[j].push_back(x);
      if (flag) {
        if (x == flag + 1)
          flag = x;
        else
          tt = flag, flag = 0;
      }
      if (x == 1) flag = 1;
    }
  }
  printf("%d", 2 * n - 2 * tt - m + 1);
  return 0;
}
