#include #include #include #include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int k; cin >> k; k--; string s; cin >> s; int n = (int)s.size(); int r = 0, c = 0; for (int i = 0; i < n; i++) { s[i] = s[i] == '#'; c += s[i]; } int i0 = k; for (int i = 0; i < k; i++) { if (s[i] != 0) { for (int j = i; j < k; j++) { r++; c -= s[j]; s[j] ^= 1; c += s[j]; } i0 = i; break; } } for (int i = i0; i < n; i++) { //for (int i = 0; i < n; i++) { // cout << ".#"[s[i]]; //} //cout << ' ' << c << ' ' << r << endl; if (c == 0) break; if (s[i] == 0) { r++; c -= s[i + 1]; s[i + 1] ^= 1; c += s[i + 1]; } else if (c == 2 && s[i] && s[i + 1]) { r += 2; c -= 2; s[i] = 0; s[i + 1] = 0; } else { r += 3; c--; s[i] = 0; } } cout << r << endl; return 0; }