#include <bits/stdc++.h>
using namespace std;
int n, k;
const int nm = 1e5 + 10;
int m[nm];
int main() {
  while (cin >> n >> k) {
    memset(m, 0, sizeof(m));
    int res = 0;
    int ans = 0;
    for (int i = 0; i < k; i++) {
      scanf("%d", &m[i]);
      int x;
      bool bl = 1;
      ans = ans + m[i] - 1;
      for (int j = 0; j < m[i]; j++) {
        scanf("%d", &x);
        if (x != j + 1)
          bl = 0;
        else if (bl)
          res++;
      }
    }
    ans = ans - res + 1 + n - res;
    cout << ans << endl;
  }
  return 0;
}
