#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <fstream>
#include <unordered_map>
#include <algorithm>
#include <queue>
using namespace std;

using ll = long long;

const int maxn = 5e5;


void solve() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]++;
  }
  ll ans = n - k;
  for (int i = n - 1; i > n - 1 - k; i--) {
    ans += a[i];
  }
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
