#include <bits/stdc++.h>
using namespace std;
int a[100100];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ans = 0, t = 0;
  for (int i = 1, b; i <= m; i++) {
    scanf("%d", &b);
    for (int j = 1; j <= b; j++) {
      scanf("%d", a + j);
      if (j > 1 and a[j] == a[j - 1] + 1) t++;
    }
    ans += b - 1;
  }
  ans -= t;
  cout << ans + (n - 1) - t << endl;
  return 0;
}
