#include <bits/stdc++.h>
using namespace std;
int n, k, m, res, cnt, tot, pre, curr;
queue<int> q;
stack<int> s;
int main() {
  std::ios::sync_with_stdio(false);
  scanf("%d%d", &n, &k);
  res = 0;
  tot = 0;
  for (int i = 1; i <= k; i++) {
    scanf("%d%d", &m, &pre);
    if (pre == 1) {
      cnt = 1;
      for (int j = 2; j <= m; j++) {
        scanf("%d", &curr);
        if (curr == pre + 1) {
          cnt++;
        } else {
          res++;
          for (int x = j + 1; x <= m; x++) {
            scanf("%d", &curr);
            res++;
          }
          break;
        }
        pre = curr;
      }
    } else {
      for (int j = 2; j <= m; j++) {
        scanf("%d", &curr);
        res++;
      }
    }
  }
  res += n - cnt;
  printf("%d\n", res);
  return 0;
}
