#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int n; int S[1000005], T[1000005]; string s; int main(void){ cin >> n >> s; S[0] = S[s.size() + 1] = 0; for (int i = 1; i <= s.size(); i++){ T[i] = 0; if (s[i - 1] == '.') S[i] = 0; else S[i] = 1; } int start[2] = { n, n }; for (int i = 1; i <= n; i++){ if (T[i] == S[i]) continue; start[0] = i; break; } for (int i = s.size(); i >= n; i--){ if (T[i] == S[i]) continue; start[1] = i; break; } int id; if (n - start[0] < start[1] - n) id = start[0]; else id = start[1]; ll ans = 0; for (int i = id; i < n; i++){ T[i] = (T[i] + 1) % 2; ans++; } for (int i = id; i > n; i--){ T[i] = (T[i] + 1) % 2; ans++; } if (id < n || (id == n&&start[1] != n)){ while (T[start[1]] != S[start[1]]){ if (T[id] == S[id]){ T[id + 1] = (T[id + 1] + 1) % 2; ans++; id++; continue; } T[id + 1] = (T[id + 1] + 1) % 2; T[id] = (T[id] + 1) % 2; ans += 2; id++; } } else if (id>n || (id == n&&start[0] != n)){ while (T[start[0]] != S[start[0]]){ if (T[id] == S[id]){ T[id - 1] = (T[id - 1] + 1) % 2; ans++; id--; continue; } T[id - 1] = (T[id - 1] + 1) % 2; T[id] = (T[id] + 1) % 2; ans += 2; } } cout << ans << endl; }