#include <bits/stdc++.h>
using namespace std;
int v[100010];
int n, k;
int main() {
  cin >> n >> k;
  int solution = 0;
  for (int i = 1; i <= k; i++) {
    int m;
    cin >> m;
    for (int j = 1; j <= m; j++) cin >> v[j];
    for (int j = 1; j <= m; j++) {
      if (j == 1 && i != 1) solution++;
      if (j != 1 && v[j] != v[j - 1] + 1) solution += 2;
    }
  }
  cout << solution << "\n";
  return 0;
}
