#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, z, k, sol, sum, ans, l, r, xx, yy, a[1000000], b[1000000];
vector<long long> v;
vector<long long> v1;
vector<long long> v2;
pair<long long, pair<long long, long long> > pp[1000000];
pair<long long, long long> p[1000000];
map<long long, long long> ma;
string s1, s2, s;
char c;
int main() {
  cin >> n >> k;
  fill(b, b + n + 2, 1);
  for (int i = 0; i < k; i++) {
    cin >> m;
    for (int q = 0; q < m; q++) {
      cin >> a[q];
    }
    for (int q = 1; q < m; q++) {
      if (a[q] - 1 != a[q - 1]) {
        b[a[q - 1]]++;
      } else {
        b[a[q - 1]]--;
      }
    }
  }
  for (int i = 1; i < n; i++) {
    sum += b[i];
  }
  cout << sum << endl;
  return 0;
}
