#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i, j, tmp[100005], m, ans = 0, x = 0, cnt = 0;
  cin >> n >> k;
  for (i = 0; i < k; i++) {
    cnt = 0;
    cin >> m;
    for (j = 0; j < m; j++) cin >> tmp[j];
    for (j = 1; j < m; j++) {
      if (tmp[j - 1] + 1 != tmp[j]) cnt++;
    }
    ans += cnt;
    ans += (cnt + 1);
  }
  ans--;
  cout << ans;
  return 0;
}
