#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int sum = n - 1;
  int temp;
  for (int i = 0; i < k; i++) {
    cin >> temp;
    int a, b, flag;
    flag = 0;
    cin >> a;
    if (a == 1) flag = 1;
    for (int i = 1; i < temp; i++) {
      cin >> b;
      if (b == a + 1 && flag == 1)
        sum--;
      else {
        sum++;
        flag = 0;
      }
      a = b;
    }
  }
  cout << sum;
}
