#include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; N--; string S; cin >> S; const int size = S.size(); vector need(size); for (int i = 0; i < size; i++) { need[i] = S[i] == '#'; } int left = size; int right = 0; for (int i = 0; i < size; i++) { if (need[i]) { left = min(left, i); right = max(right, i); } } ll ans = 0; for (int i = left; i < N; i++) { ans++; need[i] = not need[i]; if (need[i]) { right = max(right, i); } } for (int i = left; i < right; i++) { ans++; need[i + 1] = not need[i + 1]; if (need[i]) { ans += (i == right - 1 ? 1 : 2); need[i + 1] = (i == right - 1 ? need[i + 1] : not need[i + 1]); } } cout << ans << endl; return 0; }