#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1061109567;
const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int main() {
  int n, k, x, y;
  cin >> n >> k;
  int ans = 0;
  while (k--) {
    scanf("%d", &x);
    ans += x - 1;
    int tmp = -1;
    while (x--) {
      scanf("%d", &y);
      if (tmp != -1) {
        if (y == tmp + 1) ans -= 2;
      }
      tmp = y;
    }
  }
  ans += n - 1;
  cout << ans << endl;
  return 0;
}
