#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 = -2;
    for (int j = 0; j < (m); j++) {
      cin >> a;
      if (a == 1)
        b = 1;
      else if (a == b + 1) {
        b = a;
      } else {
        if (b > 0) ans++;
        b = -2;
        if (j == m - 1) {
          ans++;
        } else {
          ans += 2;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
