#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;
  bool fl = 0;
  for (int i = 1, b; i <= m; i++) {
    scanf("%d", &b);
    cin >> a[1];
    if (a[1] == 1) fl = 1;
    for (int j = 2; j <= b; j++) {
      scanf("%d", a + j);
      if (a[j] == a[j - 1] + 1 and fl)
        t++;
      else
        fl = 0;
    }
    fl = 0;
    ans += b - 1;
  }
  ans -= t;
  cout << ans + (n - 1) - t << endl;
  return 0;
}
