#include <bits/stdc++.h>using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, a;
string s;
cin >> n >> a >> s;
vector<int> h;
for (int i = 0; i < n; ++i)
if (s[i] == '#') h.push_back(i + 1); // 转为1-based位置int m = h.size();
sort(h.begin(), h.end());
long long t = 0;
int p = a, d = 1, l = 0, r = n + 1;
while (m) {
if (d == 1) { // 向右移动auto it = lower_bound(h.begin(), h.end(), p);
int nh = (it != h.end()) ? *it : r + 1;
int np = min(nh, r);
t += np - p;
p = np;
if (p == r) d = -1;
else { h.erase(it); m--; d = -1; }
} else { // 向左移动auto it = lower_bound(h.begin(), h.end(), p);
int nh = (it != h.begin()) ? *prev(it) : l - 1;
int np = max(nh, l);
t += p - np;
p = np;
if (p == l) d = 1;
else { h.erase(prev(it)); m--; d = 1; }
}
}
cout << t << '\n';
return 0;
}