#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m, ans = 0;
  cin >> n >> k;
  for (int i = 0; i < (k); i++) {
    cin >> m;
    int a, b = -1;
    for (int j = 0; j < (m); j++) {
      cin >> a;
      if (b == -1) {
        if (a != 1) ans++;
      } else if (a != b + 1) {
        ans += 2;
      }
      b = a;
    }
  }
  cout << ans << endl;
  return 0;
}
