func_code_string: #include <bits/stdc++.h>   using namespace std;   const long double pi = 3.14159265358979323846;   long long MOD = 1e9 + 7;   const char nl =   n ;   const long long inf = 1e15;   long long nxt() {     long long x;     cin >> x;     return x;   }   long long mul(long long x, long long y) {     return (1ll * (x % MOD) * (y % MOD));   }   long long modpow(long long x, long long y) {     long long z = 1;     while (y > 0) {       if (y % 2) z = mul(z, x);       x = mul(x, x);       y /= 2;     }     return z;   }   long long power(long long x, long long y) {     long long z = 1;     while (y > 0) {       if (y % 2) z = z * x;       x = x * x;       y /= 2;     }     return z;   }   long long gcd(long long a, long long b) {     if (a < b) return gcd(b, a);     if (b == 0) return a;     return gcd(b, a % b);   }   long long min(long long a, long long b) {     if (a < b) return a;     return b;   }   long long max(long long a, long long b) {     if (a > b) return a;     return b;   }   long long sq(long long a) {     long long ans = (1ll * a * a);     return ans;   }   void solve() {     long long n, k;     cin >> n >> k;     long long t[n];     vector<long long> neg;     for (long long i = 0; i < n; i++) {       cin >> t[i];       if (t[i] < 0) neg.push_back(i);     }     if ((long long)(neg.size()) > k) {       cout << -1 << nl;       return;     }     if ((long long)(neg.size()) == 0) {       cout << 0 << nl;       return;     }     if (n == 1) {       if (t[0] < 0) {         cout << 1 << nl;       } else         cout << 0 << nl;       return;     }     vector<long long> dis;     for (long long i = 0; i < (long long)(neg.size()) - 1; i++) {       if (neg[i + 1] - neg[i] > 1) {         dis.push_back(neg[i + 1] - neg[i] - 1);       }     }     sort(((dis).begin()), ((dis).end()));     long long ans = (long long)(dis.size()) * 2;     ans++;     if (t[n - 1] >= 0) ans++;     long long ewd = k - (long long)(neg.size());     for (long long x : dis) {       if (ewd >= x) ewd -= x, ans -= 2;     }     long long ex = n - 1 - neg.back();     if (ewd >= ex && ex) ans--;     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     long long TC = 1;     while (TC--) {       solve();     }     cerr <<  Time :   << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC          <<  ms n ;   }   