#include using namespace std; int main(){ int N; cin >> N; string S; cin >> S; int l = -1; int r; int cnt = 0; for (int i = 0; i < N; i++){ if (S[i] == '#'){ if (l == -1){ l = i; } r = i; cnt++; } } cout << max(N - l, cnt * 2 - 1 + (N - 1 - r)) << endl; }