#include<string>
#include<bits/stdc++.h>
#include<iostream>
using namespace std;

// driver program
int main()
{
	int n, x; 
	string s; 
	cin >> n >> x; 
	cin >> s; 
	for (int i = 0; i < n; i++)
	{
		if (x < 0) { x = 0;}
		else if (s[i] == 'x') { x += -1; }
		else if (s[i] == 'o') { x += 1; }
	}
	 if (x < 0) { x = 0; }

		
	 
	cout << x; 
}
 
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> T(H);
  rep(i, H) cin >> T[i];
  vector<vector<int>> S(H, vector<int>(W, 0));
  rep(i, H){
    rep(j, W){
      if(T[i][j] == '.')
        S[i][j] = 0;
      else
        S[i][j] = 1;
    }
  }
  S[0][0] = 1;
  S[0][W-1] = 1;
  S[H-1][0] = 1;
  S[H-1][W-1] = 1;
  vector<int> P(H+W, 1);
  int i = 0;
  int column = W, row = H;
  int k;
  int c;
  int count = 0;
  queue<int> q;
  while(i < H + W){
    if(P[i] == 0){
      i ++;
      continue;
    }
    q.push(i);
    c = 0;
    while(q.size() > 0){
      k = q.front();
      q.pop();
      if(k < H){
        rep(j, W){
          if(S[k][j] == 1 && P[H+j] == 1){
            q.push(H+j);
            P[H+j] = 0;
            c = 1;
          }
        }
      }
      else{
        rep(j, H){
          if(S[j][k-H] == 1 && P[j] == 1){
            q.push(j);
            P[j] = 0;
            c = 1;
          }
        }
      }
    }
    if(c == 1)
      P[i] = 0;
    count ++;
    i ++;
  }
  int a = 0, b = 0;
  rep(s, H){
    if(P[s] == 1)
      a ++;
  }
  for(int s = H; s < H + W; s ++){
    if(P[s] == 1)
      b ++;
  }
  cout << (count - max(a, b) - 1) << endl;
  return 0;
}