#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n + 1);
  int m = 0;
  int p = 0;
  bool o = false;
  bool g = false;
  for (int i = 0; i < k; i++) {
    cin >> v[0];
    o = false;
    g = false;
    for (int i = 1; i <= v[0]; i++) cin >> v[i];
    if (v[0] != 1) {
      for (int i = 2; i <= v[0]; i++) {
        if (v[1] == 1 && g == false) o = true;
        if (v[i] != v[i - 1] + 1) {
          m++;
          g = true;
          o = false;
        } else if (v[i - 1] != 1 && (o == false))
          p++;
      }
    }
  }
  cout << 2 * m + 2 * p + k - 1;
  return 0;
}
