#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  map<int, int> mp;
  int mx[n + 10];
  memset(mx, 0, sizeof mx);
  for (int i = 0; i < k; i++) {
    int a;
    int b;
    scanf("%d", &b);
    for (int j = 0; j < b; j++) {
      scanf("%d", &a);
      adj[i].push_back(a);
      mx[i] = max(mx[i], a);
      mp[a] = i;
    }
  }
  long long cnt = 0;
  int yes[n + 10];
  memset(yes, 0, sizeof yes);
  for (int i = 1; i < n; i++) {
    if (mp[i] == mp[i + 1] && yes[i] == 0) continue;
    int a = mp[i];
    int b = mp[i + 1];
    if (i + 1 != mx[b]) {
      yes[i + 1] = 1, cnt++;
    }
    cnt++;
    if (yes[i] == 1 || mx[a] == i) {
      continue;
    }
    yes[i] = 1;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
