//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}
template<typename C> // container
inline void sort(C& v) {
	sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }

// -------------------- Spliters ------------------------
const int maxn = 5e5+10;
//不检查ll是猪!!!

int minus1(int x, int n) {
	if(x == 0) return n - 1;
	return x - 1;
}
int add1(int x, int n) {
	if(x == n - 1) return 0;
	return x + 1;
}

char st[maxn];
int sum[maxn];
ll bi_find(int l, int r, ll dis, ll fix, int a, int T) {
	ll ans = 0;
	while(l <= r) {
		ll mid = l + r >> 1;
		if((ll)fix + sum[mid] + 2 * min(dis, mid) * a + max(dis, mid) * a + mid <= T) {
			ans = max(ans, dis + 1 + mid);
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	return ans;

}
int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	ll T;
	cin>>n>>a>>b>>T;
	cin>>st;
	ll time = 1 + (st[0] == 'w' ? b : 0);
	if(time > T) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	sum[0] = 0;
	for(int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + (st[i] == 'w' ? b : 0);
	}
	ll ans = max(1LL, bi_find(1, n - 1, 0, time, a, T));
	ll watch_time = time;
	for(int curr = n - 1; curr > 1; curr--) {
		time += 1 + (st[curr] == 'w' ? b : 0);
		ans = max(ans, bi_find(1, curr - 1, n - curr, time, a, T));
		// find position between [1, curr - 1]
		curr = minus1(curr, n);
	}
	cout<<ans<<endl;

	return 0;
}
//--USE C++11


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}
template<typename C> // container
inline void sort(C& v) {
	sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }

// -------------------- Spliters ------------------------
const int maxn = 500000+10;
//不检查ll是猪!!!

int minus1(int x, int n) {
	if(x == 0) return n - 1;
	return x - 1;
}
int add1(int x, int n) {
	if(x == n - 1) return 0;
	return x + 1;
}

char st[maxn];
ll sum[maxn];
ll bi_find(int l, int r, ll dis, ll fix, int a, ll T) {
	ll ans = 0;
	while(l <= r) {
		ll mid = l + r >> 1;
		if((ll)fix + sum[mid] + 2 * (ll)min(dis, mid) * a + (ll)max(dis, mid) * a <= T) {
			ans = max(ans, dis + 1 + mid);
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	return ans;

}
int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	ll T;
	cin>>n>>a>>b>>T;
	cin>>st;
	ll time = 1 + (st[0] == 'w' ? b : 0);
	if(time > T) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	sum[0] = 0;
	for(int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + (st[i] == 'w' ? b : 0) + 1LL;
	}
	ll ans = max(1LL, bi_find(1, n - 1, 0, time, a, T));
	ll watch_time = time;
	for(int curr = n - 1, dis = 1; curr >= 1; curr--, dis++) {
		time += 1 + (st[curr] == 'w' ? b : 0);
		if(time + dis * a <= T) {
			ans = max(ans, dis + 1LL);
		}
		ans = max(ans, bi_find(1, curr - 1, dis, time, a, T));
		// find position between [1, curr - 1]
	}
	cout<<ans<<endl;

	return 0;
}
//--USE C++11


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}
template<typename C> // container
inline void sort(C& v) {
	sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }

// -------------------- Spliters ------------------------
const int maxn = 5e5+10;
//不检查ll是猪!!!

int minus1(int x, int n) {
	if(x == 0) return n - 1;
	return x - 1;
}
int add1(int x, int n) {
	if(x == n - 1) return 0;
	return x + 1;
}

char st[maxn];
ll sum[maxn];
ll bi_find(int l, int r, ll dis, ll fix, int a, ll T) {
	ll ans = 0;
	while(l <= r) {
		ll mid = l + r >> 1;
		if((ll)fix + sum[mid] + 2 * (ll)min(dis, mid) * a + (ll)max(dis, mid) * a <= T) {
			ans = max(ans, dis + 1 + mid);
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	return ans;

}
int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	ll T;
	cin>>n>>a>>b>>T;
	cin>>st;
	ll time = 1 + (st[0] == 'w' ? b : 0);
	if(time > T) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	sum[0] = 0;
	for(int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + (st[i] == 'w' ? b : 0) + 1LL;
	}
	ll ans = max(1LL, bi_find(1, n - 1, 0, time, a, T));
	ll watch_time = time;
	for(int curr = n - 1, dis = 1; curr >= 1; curr--, dis++) {
		time += 1 + (st[curr] == 'w' ? b : 0);
		ans = max(ans, bi_find(1, curr - 1, dis, time, a, T));
		// find position between [1, curr - 1]
	}
	cout<<ans<<endl;

	return 0;
}
//--USE C++11


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}
template<typename C> // container
inline void sort(C& v) {
	sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }

// -------------------- Spliters ------------------------
const int maxn = 5e5+10;
//不检查ll是猪!!!

int minus1(int x, int n) {
	if(x == 0) return n - 1;
	return x - 1;
}
int add1(int x, int n) {
	if(x == n - 1) return 0;
	return x + 1;
}

char st[maxn];
int sum[maxn];
ll bi_find(int l, int r, ll dis, ll fix, int a, int T) {
	ll ans = 0;
	while(l <= r) {
		ll mid = l + r >> 1;
		if((ll)fix + sum[mid] + 2 * min(dis, mid) * a + max(dis, mid) * a + mid <= T) {
			ans = max(ans, dis + 1 + mid);
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	return ans;

}
int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	ll T;
	cin>>n>>a>>b>>T;
	cin>>st;
	ll time = 1 + (st[0] == 'w' ? b : 0);
	if(time > T) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	for(int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + (st[i] == 'w' ? b : 0);
	}
	ll ans = max(1LL, bi_find(1, n - 1, 0, time, a, T));
	ll watch_time = time;
	for(int curr = n - 1; curr > 1; curr--) {
		curr = minus1(curr, n);
		time += 1 + (st[curr] == 'w' ? b : 0);
		ans = max(ans, bi_find(1, curr - 1, n - curr, time, a, T));
		// find position between [1, curr - 1]
	}
	cout<<ans<<endl;

	return 0;
}
//--USE C++11


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}
template<typename C> // container
inline void sort(C& v) {
	sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }

// -------------------- Spliters ------------------------
const int maxn = 5e5+10;
//不检查ll是猪!!!

int minus1(int x, int n) {
	if(x == 0) return n - 1;
	return x - 1;
}
int add1(int x, int n) {
	if(x == n - 1) return 0;
	return x + 1;
}

char st[maxn];
int sum[maxn];
ll bi_find(int l, int r, ll dis, ll fix, int a, int T) {
	ll ans = 0;
	while(l <= r) {
		ll mid = l + r >> 1;
		if((ll)fix + sum[mid] + 2 * min(dis, mid) * a + max(dis, mid) * a + mid <= T) {
			ans = max(ans, dis + 1 + mid);
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	return ans;

}
int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	ll T;
	cin>>n>>a>>b>>T;
	cin>>st;
	ll time = 1 + (st[0] == 'w' ? b : 0);
	if(time > T) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	sum[0] = 0;
	for(int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + (st[i] == 'w' ? b : 0);
	}
	ll ans = max(1LL, bi_find(1, n - 1, 0, time, a, T));
	ll watch_time = time;
	for(int curr = n - 1; curr > 1; ) {
		time += 1 + (st[curr] == 'w' ? b : 0);
		ans = max(ans, bi_find(1, curr - 1, n - curr, time, a, T));
		// find position between [1, curr - 1]
		curr = minus1(curr, n);
	}
	cout<<ans<<endl;

	return 0;
}
//--USE C++11


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}
template<typename C> // container
inline void sort(C& v) {
	sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }

// -------------------- Spliters ------------------------
const int maxn = 5e5+10;
//不检查ll是猪!!!

int minus1(int x, int n) {
	if(x == 0) return n - 1;
	return x - 1;
}
int add1(int x, int n) {
	if(x == n - 1) return 0;
	return x + 1;
}

char st[maxn];
int sum[maxn];
ll bi_find(int l, int r, ll dis, ll fix, int a, ll T) {
	ll ans = 0;
	while(l <= r) {
		ll mid = l + r >> 1;
		if((ll)fix + sum[mid] + 2 * (ll)min(dis, mid) * a + (ll)max(dis, mid) * a <= T) {
			ans = max(ans, dis + 1 + mid);
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	return ans;

}
int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	ll T;
	cin>>n>>a>>b>>T;
	cin>>st;
	ll time = 1 + (st[0] == 'w' ? b : 0);
	if(time > T) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	sum[0] = 0;
	for(int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + (st[i] == 'w' ? b : 0) + 1LL;
	}
	ll ans = max(1LL, bi_find(1, n - 1, 0, time, a, T));
	ll watch_time = time;
	for(int curr = n - 1; curr >= 1; curr--) {
		time += 1 + (st[curr] == 'w' ? b : 0);
		ans = max(ans, bi_find(1, curr - 1, n - curr, time, a, T));
		// find position between [1, curr - 1]
	}
	cout<<ans<<endl;

	return 0;
}
//--USE C++11


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}
template<typename C> // container
inline void sort(C& v) {
	sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }

// -------------------- Spliters ------------------------
const int maxn = 5e5+10;
//不检查ll是猪!!!

int minus1(int x, int n) {
	if(x == 0) return n - 1;
	return x - 1;
}
int add1(int x, int n) {
	if(x == n - 1) return 0;
	return x + 1;
}

char st[maxn];
int sum[maxn];
ll bi_find(int l, int r, ll dis, ll fix, int a, int T) {
	ll ans = 0;
	while(l <= r) {
		ll mid = l + r >> 1;
		if((ll)fix + sum[mid] + 2 * min(dis, mid) * a + max(dis, mid) * a + mid <= T) {
			ans = max(ans, dis + 1 + mid);
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	return ans;

}
int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	ll T;
	cin>>n>>a>>b>>T;
	cin>>st;
	ll time = 1 + (st[0] == 'w' ? b : 0);
	if(time > T) {
		cout<<0<<endl;
		return 0;
	}
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	sum[0] = 0;
	for(int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + (st[i] == 'w' ? b : 0);
	}
	ll ans = max(1LL, bi_find(1, n - 1, 0, time, a, T));
	ll watch_time = time;
	for(int curr = n - 1; curr >= 1; ) {
		time += 1 + (st[curr] == 'w' ? b : 0);
		ans = max(ans, bi_find(1, curr - 1, n - curr, time, a, T));
		// find position between [1, curr - 1]
		curr = minus1(curr, n);
	}
	cout<<ans<<endl;

	return 0;
}
//--USE C++11


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx];

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(ll i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin >> n >> aa >> b >> t;
	cin >> s;
	t -= (1) + (s[0] == 'w' ? b : 0);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + 1 + (s[n - i - 1] == 'w' ? b : 0)      );
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + 1 + (s[i] == 'w' ? b : 0));
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	for(int i = 0; i < n; i++)
	{
		ll r = aztah[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(azsar, azsar + n, tmp) - azsar - 1;
		tmp -= azsar[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin >> n >> aa >> b >> t;
	cin >> s;
	t -= (1) + (s[0] == 'w' ? b : 0);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + 1 + (s[n - i - 1] == 'w' ? b : 0)      );
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + 1 + (s[i] == 'w' ? b : 0));
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 1; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			break;
		tmp -= (i * aa);
		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	for(int i = 1; i < n; i++)
	{
		ll r = aztah[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			break;
		tmp -= (i * aa);
		d = max(d, i + (long long)1);
		int g = upper_bound(azsar, azsar + n, tmp) - azsar - 1;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	cerr << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + 1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

int main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cout << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			continue;
		int g = upper_bound(aztah + 1, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cout << g << " " << aztah[g] << " " << i << " " << azsar[i] << " " << aztah[i] << endl;
	}

	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

int a[maxx];

int main()
{
	int aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (aa + a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	int in1 = 1, in2 = s.length() - 1;
	while (t > 0 && in1 <= in2)
	{
		int r;
		if (a[in1] <= a[in2])
		{
			r = in1;
		}
		else
		{
			r = in2;
		}
		t -= (a[r]);
		if (t < 0)
		{
			cout << d << endl;
			return 0;
		}
		d++;
		t -= (aa);
	}
	if (t <= 0)
	{
		cout << d << endl;
		return 0;
	}
	else
	{
		cout << n << endl;
		return 0;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> aa >> b >> t;
	cin >> s;
	for(ll i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

long long a[maxx];

int main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	t -= aa;
	if (t <= 0)
	{
		cout << d << endl;
		return 0;
	}

	long long in1 = 1, in2 = s.length() - 1;
	while (t > 0 && in1 <= in2)
	{
		int r;
		if (a[in1] <= a[in2])
		{
			r = in1;
			in1++;
		}
		else
		{
			r = in2;
			in2--;
		}
		t -= (a[r]);
		if (t < 0)
		{
			cout << d << endl;
			return 0;
		}
		d++;
		t -= (aa);
		if (t <= 0)
		{
			cout << d << endl;
			return 0;
		}
		if (d == n)
		{
			cout << d << endl;
			return 0;
		}
//		cerr << in1 << " " << in2 << " ! " << t << " " << d << endl;
	}
	if (t <= 0)
	{
		cout << d << endl;
		return 0;
	}
	else
	{
		cout << d << endl;
		return 0;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin >> n >> aa >> b >> t;
	cin >> s;
	t -= (1) + (s[0] == 'w' ? b : 0);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + 1 + (s[n - i - 1] == 'w' ? b : 0)      );
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + 1 + (s[i] == 'w' ? b : 0));
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	cerr << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
	for(int i = 0; i < n; i++)
	{
		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + 1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cout << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			continue;
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cout << g << " " << aztah[g] << " " << i << " " << azsar[i] << " " << aztah[i] << endl;
	}

	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

int a[maxx];

int main()
{
	int aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (aa + a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	int in1 = 1, in2 = s.length() - 1;
	while (t > 0 && in1 <= in2)
	{
		int r;
		if (a[in1] <= a[in2])
		{
			r = in1;
			in1++;
		}
		else
		{
			r = in2;
			in2--;
		}
		t -= (a[r]);
		if (t < 0)
		{
			cout << d << endl;
			return 0;
		}
		d++;
		t -= (aa);
//		cerr << in1 << " " << in2 << " ! " << t << " " << d << endl;
	}
	if (t <= 0)
	{
		cout << d << endl;
		return 0;
	}
	else
	{
		cout << n << endl;
		return 0;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cout << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			continue;
		int g = upper_bound(aztah + 1, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cout << g << " " << aztah[g] << " " << i << " " << azsar[i] << " " << aztah[i] << endl;
	}

	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin >> n >> aa >> b >> t;
	cin >> s;
	t -= (1) + (s[0] == 'w' ? b : 0);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + 1 + (s[n - i - 1] == 'w' ? b : 0)      );
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + 1 + (s[i] == 'w' ? b : 0));
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 1; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			break;
		tmp -= (i * aa);
//		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	for(int i = 1; i < n; i++)
	{
		ll r = aztah[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			break;
		tmp -= (i * aa);
//		d = max(d, i + (long long)1);
		int g = upper_bound(azsar, azsar + n, tmp) - azsar - 1;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

int main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cout << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			continue;
		int g = upper_bound(aztah + 1, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cout << g << " " << aztah[g] << " " << i << " " << azsar[i] << " " << aztah[i] << endl;
	}

	cout << d << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

main()
{
	ios::sync_with_stdio(false);
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	cerr << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + 1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin >> n >> aa >> b >> t;
	cin >> s;
	t -= (1) + (s[0] == 'w' ? b : 0);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cerr << t << " !!" << endl;
	for(int i = 1; i <= n; i++)
	{
		aztah[i] = aztah[i - 1];
		aztah[i] += (aa + 1 + (s[n - i] == 'w' ? b : 0)      );
		if (i == n)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + 1 + (s[i] == 'w' ? b : 0));
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 1; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			break;
		tmp -= (i * aa);
//		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		d = max(d, max((long long)g, 0ll) + i + 1);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	for(int i = 1; i < n; i++)
	{
		ll r = aztah[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			break;
		tmp -= (i * aa);
//		d = max(d, i + (long long)1);
		int g = upper_bound(azsar, azsar + n, tmp) - azsar - 1;
		d = max(d, max((long long)g, 0ll) + i + 1);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

long long a[maxx];

int main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (aa + a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	long long in1 = 1, in2 = s.length() - 1;
	while (t > 0 && in1 <= in2)
	{
		int r;
		if (a[in1] <= a[in2])
		{
			r = in1;
			in1++;
		}
		else
		{
			r = in2;
			in2--;
		}
		t -= (a[r]);
		if (t < 0)
		{
			cout << d << endl;
			return 0;
		}
		d++;
		t -= (aa);
//		cerr << in1 << " " << in2 << " ! " << t << " " << d << endl;
	}
	if (t <= 0)
	{
		cout << d << endl;
		return 0;
	}
	else
	{
		cout << n << endl;
		return 0;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

long long a[maxx];

int main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	t -= aa;
	if (t < 0)
	{
		cout << d << endl;
		return 0;
	}

	long long in1 = 1, in2 = s.length() - 1;
	while (t > 0 && in1 <= in2)
	{
		int r;
		if (a[in1] <= a[in2])
		{
			r = in1;
			in1++;
		}
		else
		{
			r = in2;
			in2--;
		}
		t -= (a[r]);
		if (t < 0)
		{
			cout << d << endl;
			return 0;
		}
		d++;
		t -= (aa);
//		cerr << in1 << " " << in2 << " ! " << t << " " << d << endl;
	}
	if (t <= 0)
	{
		cout << d << endl;
		return 0;
	}
	else
	{
		cout << n << endl;
		return 0;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cout << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			continue;
		d = max(d, i + 1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cout << g << " " << aztah[g] << " " << i << " " << azsar[i] << " " << aztah[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

int main()
{
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	t -= aa;
	if (t < 0)
	{
		cout << d << endl;
		return 0;
	}
//	cout << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
	for(int i = 1; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		if (tmp < 0)
			continue;
		int g = upper_bound(aztah + 1, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
	//	cout << g << " " << aztah[g] << " " << i << " " << azsar[i] << " " << aztah[i] << endl;
	}

	cout << d << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin >> n >> aa >> b >> t;
	cin >> s;
	t -= (1) + (s[0] == 'w' ? b : 0);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + 1 + (s[n - i - 1] == 'w' ? b : 0)      );
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + 1 + (s[i] == 'w' ? b : 0));
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxx = 5e5 + 20;

ll a[maxx], aztah[maxx], azsar[maxx],aa, b, n, t, d = 0;
string s;

main()
{
	ios::sync_with_stdio(false);
	cin >> n >> aa >> b >> t;
	cin >> s;
	t -= (1) + (s[0] == 'w' ? b : 0);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
//	cerr << t << " !!" << endl;
	for(int i = 0; i < n; i++)
	{
		if (i)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + 1 + (s[n - i - 1] == 'w' ? b : 0)      );
		if (!i)
			continue;
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + 1 + (s[i] == 'w' ? b : 0));
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 1; i < n; i++)
	{
		ll r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	for(int i = 1; i < n; i++)
	{
		ll r = aztah[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + (long long)1);
		int g = upper_bound(azsar, azsar + n, tmp) - azsar - 1;
		tmp -= azsar[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
//		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxx = 5e5 + 20;

long long a[maxx], aztah[maxx], azsar[maxx];

main()
{
	ios::sync_with_stdio(false);
	long long aa, b, n, t, d = 0;
	cin >> n >> aa >> b >> t;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'w')
		{
			a[i] = b + 1;
		}
		else
		{
			a[i] = 1;
		}
	}
	t -= (a[0]);
	if (t < 0)
	{
		cout << 0 << endl;
		return 0;
	}
	d++;
	cerr << t << " !!" << endl;
	long long in1 = 1, in2 = s.length() - 1;
	for(int i = 1; i < n; i++)
	{
		azsar[i] = azsar[i - 1];
		azsar[i] += (aa + a[i]);
	}
	for(int i = 0; i < n; i++)
	{
		if (i > 0)
			aztah[i] = aztah[i - 1];
		aztah[i] += (aa + a[n - i - 1]);
	}
//	for(int i = 0; i < n; i++)
//	{
//		cerr << i << " : " << azsar[i] <<  " " << aztah[i] << endl;
//	}
	for(int i = 0; i < n; i++)
	{
		int r = azsar[i], tmp = t;
		tmp -= r;
		tmp -= (i * aa);
		if (tmp < 0)
			continue;
		d = max(d, i + 1);
		int g = upper_bound(aztah, aztah + n, tmp) - aztah - 1;
		tmp -= aztah[g];
		if (tmp < 0)
			continue;
		d = max(d, (long long)g + i + 2);
		cerr << g << " " << aztah[g] << " " << i << " " << azsar[i] << endl;
	}
	cout << min(d, n) << endl;
	return 0;

}


#include <bits/stdc++.h>
using namespace std;
int pre[500010],pp[500010];
int main()
{
	int n,a,b,t;
	string s;
	cin>>n>>a>>b>>t>>s;pre[0]=1+(s[0]=='w'?b:0);pp[0]=1+a+(s[n-1]=='w'?b:0);
	for(int i=1;i<n;i++)pre[i]=pre[i-1]+(s[i]=='w'?b:0)+a+1;
	for(int i=1;i<n;i++)pp[i]=pp[i-1]+(s[n-i-1]=='w'?b:0)+a+1;
	int ans=0;
	int sum,time=0;
	for(int i=0;i<n;i++)
	{
		i!=0?time+=a:time=time;
		sum=pre[i]; if(sum==t){ans=max(ans,i+1);break;
	   }
		sum+=time;
		if(sum<t){

		int x=lower_bound(pp+0,pp+n-i-1,t-sum)-pp;
		//cout<<x<<"\n";
		ans=max(ans,x+i+1);
	   }

	   else
		{
			sum-=time;
		  break;
	    }
	}
	int x=lower_bound(pre+0,pre+n,t)-pre;
	int z=lower_bound(pp+0,pp+n,t)-pp;

	cout<<max(ans,max(x,z))<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
int pre[500010],pp[500010];
void  print(int a[],int n)
{
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<"\n";
}
int main()
{
	int n,a,b,t;
	string s;
	cin>>n>>a>>b>>t>>s;pre[0]=1+(s[0]=='w'?b:0);pp[0]=1+a+(s[n-1]=='w'?b:0);
	for(int i=1;i<n;i++)pre[i]=pre[i-1]+(s[i]=='w'?b:0)+a+1;
	for(int i=1;i<n;i++)pp[i]=pp[i-1]+(s[n-i-1]=='w'?b:0)+a+1;
	int ans=0;
	int sum,time=0;
	for(int i=0;i<n;i++)
	{
		i!=0?time+=a:time=time;
		sum=pre[i]; if(sum==t){ans=max(ans,i+1);break;
	   }
		sum+=time;
		if(sum<t){

		int x=lower_bound(pp+0,pp+n-i-1,t-sum)-pp;
		//cout<<x<<"\n";
		ans=max(ans,x+i+1);
	   }

	   else
		{
			sum-=time;
		  break;
	    }
	}
	//print(pre,n);print(pp,n);
	int x=lower_bound(pre+0,pre+n,t)-pre+1;
	int z=lower_bound(pp+0,pp+n,t-pre[0])-pp+2;
	//cout<<ans<<" "<<x<<" "<<z<<"\n";

	cout<<max(ans,max(x,z))<<"\n";
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int n,m,count=0,i,j,k,l,min;
        cin>>n>>m;
        vector<int>v;
        char a[n][m];
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(a[i][j]=='*')
                    count++;
                    for(k=j-1;k>=0;k--)
                    {
                     if(a[i][k]=='*')
                        count++;
                    }
                    for(k=j+1;k<m;k++)
                    {
                        if(a[i][k]=='*')
                            count++;
                    }
                    for(k=i-1;k>=0;k--)
                    {
                        if(a[k][j]=='*')
                            count++;
                    }
                    for(k=i+1;k<n;k++)
                    {
                        if(a[k][j]=='*')
                            count++;
                    }
                 l=(m+n-count-1);
                 min=l;
                 if(l<min)
                    min=l;

                    count=0;
            }
        }
        cout<<min<<endl;

    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,m,i,j,count=0;
        vector<int>v;
        cin>>n>>m;
        char a[n][m];
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='.')
                    count++;
            }
            v.push_back(count);
            count=0;
        }
        count=0;
        for(i=0;i<m;i++)
        {
            for(j=0;j<n;j++)
            {
                if(a[j][i]=='.')
                    count++;

            }
            v.push_back(count);
            count=0;

        }
        count=0;
        sort(v.begin(),v.end());
        cout<<v[0]<<endl;

    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int n,m,count=0,i,j,k,l;
        cin>>n>>m;
        vector<int>v;
        char a[n][m];
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                cin>>a[i][j];
            }
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(a[i][j]=='*')
                    count++;
                    for(k=j-1;k>=0;k--)
                    {
                     if(a[i][k]=='*')
                        count++;
                    }
                    for(k=j+1;k<m;k++)
                    {
                        if(a[i][k]=='*')
                            count++;
                    }
                    for(k=i-1;k>=0;k--)
                    {
                        if(a[k][j]=='*')
                            count++;
                    }
                    for(k=i+1;k<n;k++)
                    {
                        if(a[k][j]=='*')
                            count++;
                    }
                    v.push_back(m+n-count-1);
                    count=0;
            }
        }
        sort(v.begin(),v.end());
        cout<<v[0]<<endl;

    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int n,m,count=0,i,j,k,l,min=1000000,x=0,y=0;
        cin>>n>>m;
        vector<int> v1,v2;
        char a[n][m];
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='*')
                    x++;
            }
            v1.push_back(x);
            x=0;
        }
        for(j=0;j<m;j++)
        {
            for(i=0;i<n;i++)
            {
                if(a[i][j]=='*')
                    y++;
            }
            v2.push_back(y);
            y=0;
        }
        sort(v1.begin(),v1.end());
        sort(v2.begin(),v2.end());
        cout<<m+n-(v1[v1.size()-1]+v2[v2.size()-1])<<endl;
    }
    return 0;
}


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

     int main()
     {
         int t;
         cin>>t;
         while(t--)
         {
             vector<int>v;
             int n,m,f=0;
             cin>>n>>m;
             char a[n][m];
             int i,j,k;
             for(i=0;i<n;i++)
             {
                 for(j=0;j<m;j++)
                 {
                     cin>>a[i][j];
                 }
             }
             for(i=0;i<n;i++)
             {
                 for(j=0;j<m;j++)
                 {
                     int count=0;
                     if(a[i][j]=='*')
                     {
                         f=1;
                         for(k=i-1;k>=0;k--)

                         {
                            if(a[k][j]=='.')
                            count++;
                         }
                         for(k=i+1;k<n;k++)
                         {
                             if(a[k][j]=='.')
                                count++;
                         }
                         for(k=j-1;k>=0;k--)
                         {
                             if(a[i][k]=='.')
                                count++;
                         }
                         for(k=j+1;k<m;k++)
                         {
                             if(a[i][k]=='.')
                                count++;
                         }
                         v.push_back(count);
                     }
                 }
             }
             sort(v.begin(),v.end());
             if(f==1)
                cout<<v[0]<<endl;
             else
                cout<<m+n-1<<endl;

         }
     }


		#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define pii acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 3000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
#define mod 100000009
#define faster ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
#define rep(i,a,b) int i ; for( i=a;i<b;i++);
#define int long long
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    faster;
   	int q;
   	cin >> q;
   	while(q--){

   		int n,m;
   		cin >> n >> m;
   		char matrix[n+1][m+1];
   		for(int i=0;i<n;i++){

   			for(int j=0;j<m;j++){

   				cin >> matrix[i][j];
   			}
   		}
   		int maxrow = 10e9,maxcol=10e9,idx;
   		for(int i=0;i<n;i++){

   			int sum=0;
   			for(int j=0;j<m;j++){

   				if(matrix[i][j]=='.')
   					sum++;
   			}
   			if(sum < maxrow){
   			idx = i;
   			maxrow = min(maxrow,sum);}
   		}
   		set<pi>b;
   		map<pi,bool>check;
   		//cout << idx << endl;
   		for(int j=0;j<m;j++){

   			if(matrix[idx][j]=='.'){

   			//	cout << j << ' ' ;
   				check[{idx,j}]=true;
   			}
   		}
   		//cout << endl;
   		int msi = 0;
   		for(int i=0;i<m;i++){

   			int sum=0;
   			int si=0;
   			for(int j=0;j<n;j++){

   				if(matrix[j][i]=='.'){

   					sum++;
   					if(check[{j,i}]==true)
   						si = 1;
   				}
   			}

   			if(maxcol > sum-si){
   			maxcol = min(maxcol,sum);
   			msi = si;}

   		}
   	//	cout << maxrow << ' ' << maxcol << ' ' << msi << endl;
   		int ans = maxrow + maxcol;
   		if(ans==0){

   			cout << ans << endl;;
   		}
   		else{

   			cout << ans - msi << endl;
   		}
   	}
    return 0;

}


		#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define pii acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 3000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
#define mod 100000009
#define faster ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
#define rep(i,a,b) int i ; for( i=a;i<b;i++);
#define int long long
using namespace std;
int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    faster;
   	int q;
   	cin >> q;
   	while(q--){

   		int n,m;
   		cin >> n >> m;
   		char matrix[n+1][m+1];
   		for(int i=0;i<n;i++){

   			for(int j=0;j<m;j++){

   				cin >> matrix[i][j];
   			}
   		}
   		int maxrow = -1,maxcol=-1;
   		for(int i=0;i<n;i++){

   			int sum=0;
   			for(int j=0;j<m;j++){

   				if(matrix[i][j]=='*')
   					sum++;
   			}
   			maxrow = max(maxrow,sum);
   		}
   		for(int i=0;i<m;i++){

   			int sum = 0;
   			for(int j=0;j<n;j++){

   				if(matrix[j][i]=='*')
   					sum++;
   			}
   			maxcol = max(maxcol,sum);
   		}
   		cout << n-maxrow + m-maxcol << endl;
   	}
    return 0;

}


		#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define pii acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 3000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
#define mod 100000009
#define faster ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
#define rep(i,a,b) int i ; for( i=a;i<b;i++);
#define int long long
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    faster;
   	int q;
   	cin >> q;
   	while(q--){

   		int n,m;
   		cin >> n >> m;
   		char matrix[n+1][m+1];
   		for(int i=0;i<n;i++){

   			for(int j=0;j<m;j++){

   				cin >> matrix[i][j];
   			}
   		}
   		int maxrow = 10e9,maxcol=10e9,idx;
   		for(int i=0;i<n;i++){

   			int sum=0;
   			for(int j=0;j<m;j++){

   				if(matrix[i][j]=='.')
   					sum++;
   			}
   			if(sum < maxrow){
   			idx = i;
   			maxrow = min(maxrow,sum);}
   		}
   		set<pi>b;
   		map<pi,bool>check;
   		//cout << idx << endl;
   		for(int j=0;j<m;j++){

   			if(matrix[idx][j]=='.'){

   			//	cout << j << ' ' ;
   				check[{idx,j}]=true;
   			}
   		}
   		//cout << endl;
   		int msi = 0;
   		for(int i=0;i<m;i++){

   			int sum=0;
   			int si=0;
   			for(int j=0;j<n;j++){

   				if(matrix[j][i]=='.'){

   					sum++;
   					if(check[{j,i}]==true)
   						si = 1;
   				}
   			}

   			if(maxcol > sum){
   			maxcol = min(maxcol,sum);
   			msi = si;}
   		}
   	//	cout << maxrow << ' ' << maxcol << ' ' << msi << endl;
   		int ans = maxrow + maxcol;
   		if(ans==0){

   			cout << ans << endl;;
   		}
   		else{

   			cout << ans - msi << endl;
   		}
   	}
    return 0;

}


		#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define pii acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 3000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
#define mod 100000009
#define faster ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
#define rep(i,a,b) int i ; for( i=a;i<b;i++);
#define int long long
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    faster;
   	int q;
   	cin >> q;
   	while(q--){

   		int n,m;
   		cin >> n >> m;
   		char matrix[n+1][m+1];
   		for(int i=0;i<n;i++){

   			for(int j=0;j<m;j++){

   				cin >> matrix[i][j];
   			}
   		}
   		int maxrow = -1,maxcol=-1;
   		for(int i=0;i<n;i++){

   			int sum=0;
   			for(int j=0;j<m;j++){

   				if(matrix[i][j]=='*')
   					sum++;
   			}
   			maxrow = max(maxrow,sum);
   		}
   		for(int i=0;i<m;i++){

   			int sum = 0;
   			for(int j=0;j<n;j++){

   				if(matrix[j][i]=='*')
   					sum++;
   			}
   			maxcol = max(maxcol,sum);
   		}
   		cout << n-maxrow + m-maxcol << endl;
   	}
    return 0;

}


		#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define pii acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 3000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
#define mod 100000009
#define faster ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
#define rep(i,a,b) int i ; for( i=a;i<b;i++);
#define int long long
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    faster;
   	int q;
   	cin >> q;
   	while(q--){

   		int n,m;
   		cin >> n >> m;
   		char matrix[n+1][m+1];
   		for(int i=0;i<n;i++){

   			for(int j=0;j<m;j++){

   				cin >> matrix[i][j];
   			}
   		}
   		int maxrow = 10e9,maxcol=10e9,idx;
   		for(int i=0;i<n;i++){

   			int sum=0;
   			for(int j=0;j<m;j++){

   				if(matrix[i][j]=='.')
   					sum++;
   			}
   			if(sum < maxrow){
   			idx = i;
   			maxrow = min(maxrow,sum);}
   		}
   		for(int i=0;i<m;i++){

   			int ans=0;
   			for(int j=0;j<n;++j){

   				if(j!=idx){

   					if(matrix[j][i]=='.')
   						ans++;
   				}
   			}
   			maxcol = min(maxcol,ans);
   		}
   		cout << maxcol+maxrow<< endl;
   	}
    return 0;

}


		#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define pii acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 3000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
#define mod 100000009
#define faster ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
#define rep(i,a,b) int i ; for( i=a;i<b;i++);
#define int long long
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    faster;
   	int q;
   	cin >> q;
   	while(q--){

   		int n,m;
   		cin >> n >> m;
   		char matrix[n+1][m+1];
   		for(int i=0;i<n;i++){

   			for(int j=0;j<m;j++){

   				cin >> matrix[i][j];
   			}
   		}
   		int maxrow = 10e9,maxcol=10e9,idx;
   		for(int i=0;i<n;i++){

   			int sum=0;
   			for(int j=0;j<m;j++){

   				if(matrix[i][j]=='.')
   					sum++;
   			}
   			if(sum < maxrow){
   			idx = i;
   			maxrow = min(maxrow,sum);}
   		}
   		set<pi>b;
   		map<pi,bool>check;
   		//cout << idx << endl;
   		for(int j=0;j<m;j++){

   			if(matrix[idx][j]=='.'){

   			//	cout << j << ' ' ;
   				check[{idx,j}]=true;
   			}
   		}
   		//cout << endl;
   		int msi = 0;
   		for(int i=0;i<m;i++){

   			int sum=0;
   			int si=0;
   			for(int j=0;j<n;j++){

   				if(matrix[j][i]=='.'){

   					sum++;
   					if(check[{j,i}]==true)
   						si = 1;
   				}
   			}

   			if(maxcol > sum){
   			maxcol = min(maxcol,sum);
   			msi = si;}
   			else if(maxcol == sum && si > msi){

   				maxcol = min(maxcol,sum);
   			   msi = si;
   			}
   		}
   	//	cout << maxrow << ' ' << maxcol << ' ' << msi << endl;
   		int ans = maxrow + maxcol;
   		if(ans==0){

   			cout << ans << endl;;
   		}
   		else{

   			cout << ans - msi << endl;
   		}
   	}
    return 0;

}


		#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define pii acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 3000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
#define mod 100000009
#define faster ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
#define rep(i,a,b) int i ; for( i=a;i<b;i++);
#define int long long
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    faster;
   	int q;
   	cin >> q;
   	while(q--){

   		int n,m;
   		cin >> n >> m;
   		char matrix[n+1][m+1];
   		vi rowsum(n+1,0),colsum(m+1,0);
   		for(int i=0;i<n;i++){

   			int sum=0;
   			for(int j=0;j<m;j++){

   				cin >> matrix[i][j];
   				if(matrix[i][j]=='.')
   					sum++;
   			}
   			rowsum[i] = sum;
   		}
   		for(int i=0;i<m;i++)
   		{
   			int ans  = 0;
   			for(int j=0;j<n;j++){

   				if(matrix[j][i]=='.')
   					ans++;
   			}
   			colsum[i] = ans;
   		}
   		int minans = 10e12;
   		for(int i=0;i<n;i++){

   			for(int j=0;j<m;j++){

   				int c;
   				if(matrix[i][j]=='.')
   					c=1;
   				else
   					c=0;
   				minans = min(minans,rowsum[i]+colsum[j]-c);
   			}
   		}
   		cout << minans << endl;

   	}
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='.')
				{
					c1++;
				}
			}
			r[i] = c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='.')
				{
					c1++;
				}
			}
			c[i] = c1;
		}
		ll mn = inf;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				mn = min(r[i]+c[j]-(a[i][j]=='.'),mn);
			}
		}
		cout<<mn<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='.')
				{
					c1++;
				}
			}
			r[i] = c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='.')
				{
					c1++;
				}
			}
			c[i] = c1;
		}
		int mn1,mn2;
		int v1 = 1e9,v2 = 1e9;
		for(i=0;i<n;i++)
		{
			if(r[i]<v1)
			{
				mn1 = i;
				v1 = r[i];
			}
		}
		for(i=0;i<m;i++)
		{
			if(c[i]<v2)
			{
				mn2 = i;
				v2 = c[i];
			}
		}
		int ans = 0;
		for(j=0;j<m;j++)
		{
			if(a[mn1][j]=='.')
			{
				ans++;
				a[mn1][j] = '*';
			}
		}
		for(i=0;i<n;i++)
		{
			if(a[i][mn2]=='.')
			{
				ans++;
			}
		}
		cout<<ans<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='.')
				{
					c1++;
				}
			}
			r[i] = c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='.')
				{
					c1++;
				}
			}
			c[i] = c1;
		}
		int mn1,mn2;
		int v1 = 1e9,v2 = 1e9;
		for(i=0;i<n;i++)
		{
			if(r[i]<v1)
			{
				mn1 = i;
				v1 = r[i];
			}
		}
		for(i=0;i<m;i++)
		{
			if(c[i]<v2)
			{
				mn2 = i;
				v2 = c[i];
			}
		}
		int ans = 0;
		for(j=0;j<m;j++)
		{
			if(a[mn1][j]=='.')
			{
				ans++;
				a[mn1][j] = '*';
				c[j]--;
			}
		}
		ll mn = 1e9;
		for(j=0;j<m;j++)
			mn = min(mn,c[j]);
		cout<<ans+mn<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='.')
				{
					c1++;
				}
			}
			r[i] = c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='.')
				{
					c1++;
				}
			}
			c[i] = c1;
		}
		int mn1,mn2;
		int v1 = 1e9,v2 = 1e9;
		for(i=0;i<n;i++)
		{
			if(r[i]<v1)
			{
				mn1 = i;
				v1 = r[i];
			}
		}
		for(i=0;i<m;i++)
		{
			if(c[i]<v2)
			{
				mn2 = i;
				v2 = c[i];
			}
		}
		int ans = 0;
		for(j=0;j<m;j++)
		{
			if(a[mn1][j]=='.')
			{
				ans++;
				a[mn1][j] = '*';
				c[j]--;
			}
		}
		int mn = 1e9;
		for(j=0;j<m;j++)
			mn = min(mn,c[j]);
		cout<<ans+mn<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='*')
					c++;
			}
			r[i] = m-c;
		}
		for(i=0;i<m;i++)
		{	ll c = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='*')
					c++;
			}
			c[i] = n-c;
		}
		sort(r,r+n);
		sort(c,c+m);
		cout<<r[0]+c[0]<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='.')
				{
					c1++;
				}
			}
			r[i] = c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='.')
				{
					c1++;
				}
			}
			c[i] = c1;
		}
		ll mn = inf;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				mn = min(r[i]+c[j]+(a[i][j]=='.'),mn);
			}
		}
		cout<<mn<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='*')
					c1++;
			}
			r[i] = m-c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='*')
					c1++;
			}
			c[i] = n-c1;
		}
		sort(r,r+n);
		sort(c,c+m);
		cout<<r[0]+c[0]<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='*')
				{
					c1++;
				}
			}
			r[i] = m-c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='*'||i==j)
				{
					c1++;
				}
			}
			c[i] = n-c1;
		}
		sort(r,r+n);
		sort(c,c+m);
		cout<<r[0]+c[0]<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='*')
				{
					c1++;
				}
			}
			r[i] = m-c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='*')
				{
					c1++;
				}
			}
			c[i] = n-c1;
		}
		int mn1 = 0,mn2 = 0;
		int v1 = r[0],v2 = c[0];
		for(i=1;i<n;i++)
		{
			if(r[i]<v1)
			{
				mn1 = i;
				v1 = r[i];
			}
		}
		for(i=1;i<m;i++)
		{
			if(c[i]<v2)
			{
				mn2 = i;
				v2 = c[i];
			}
		}
		int ans = 0;
		for(j=0;j<m;j++)
		{
			if(a[mn1][j]=='.')
			{
				ans++;
				a[mn1][j] = '*';
			}
		}
		for(i=0;i<n;i++)
		{
			if(a[i][mn2]=='.')
			{
				ans++;
			}
		}
		cout<<ans<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define NIKHIL_SETHI          cout.tie(0);
#define MNNIT_ALLAHABAD       cin.tie(0);
#define umii                  unordered_map<ll,ll>
#define mii                   map<ll,ll>
#define pii                   pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define forP(i,j,k)           for(i=j; i<k; i++)
#define forN(i,j,k)           for(i=j; i>k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define inf 1e18

//mainly used functions
bool prime[10000001];
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
void sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		ll r[n],c[m],i,j;
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
			}
		}
		for(i=0;i<n;i++)
		{
			ll c1 = 0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]=='*')
				{
					c1++;
				}
			}
			r[i] = m-c1;
		}
		for(i=0;i<m;i++)
		{	ll c1 = 0;
			for(j=0;j<n;j++)
			{
				if(a[j][i]=='*')
				{
					c1++;
				}
			}
			c[i] = n-c1;
		}
		int mn1,mn2;
		int v1 = 1e9,v2 = 1e9;
		for(i=0;i<n;i++)
		{
			if(r[i]<v1)
			{
				mn1 = i;
				v1 = r[i];
			}
		}
		for(i=0;i<m;i++)
		{
			if(c[i]<v2)
			{
				mn2 = i;
				v2 = c[i];
			}
		}
		int ans = 0;
		for(j=0;j<m;j++)
		{
			if(a[mn1][j]=='.')
			{
				ans++;
				a[mn1][j] = '*';
			}
		}
		for(i=0;i<n;i++)
		{
			if(a[i][mn2]=='.')
			{
				ans++;
			}
		}
		cout<<ans<<"\n";
	}
}


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

//std::vector<pair<int *, int *>> v;

int main(int argc, char const *argv[]) {
  int q;
  cin>>q;
  while(q--){
    int n, m;
    cin>>n>>m;
    int iarr[n]={0};
    int jarr[m]={0};
    char str[n][m];
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
        char c;
        cin>>c;
        str[i][j]=c;
        if(c == '*'){
          iarr[i]++;
          jarr[j]++;

        }
      }
    }

    int a=0, b=0, inda, indb;
    for(int i=0; i<n; i++){
      if(iarr[i]>a) a = iarr[i], inda = i;
    }

    for(int i=0; i<m; i++){
      if(jarr[i]>b) b = jarr[i], indb=i;
    }

    long ans = (n-a+m-b);
    if(ans != 0) { if(str[inda][indb] == '.') ans--; }

    cout<<ans<<"\n";
  }
}


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

//std::vector<pair<long long *, long long *>> v;

int main(int argc, char const *argv[]) {
  long long q;
  cin>>q;
  while(q--){
    long long n, m;
    cin>>n>>m;
    long long iarr[n]={0};
    long long jarr[m]={0};
    char str[n][m];
    for(long long i=0; i<n; i++) {
      for(long long j=0; j<m; j++) {
        char c;
        cin>>c;
        str[i][j]=c;
        if(c == '*'){
          iarr[i]++;
          jarr[j]++;

        }
      }
    }
    std::vector<long long> indb, inda;
    long long a=0, b=0;
    for(long long i=0; i<n; i++){
      if(iarr[i]>=a) a = iarr[i];
    }

    for(long long i=0; i<m; i++){
      if(jarr[i]>=b) b = jarr[i];
    }

    for(long long i=0; i<n; i++){
      if(iarr[i]==a) inda.push_back(i);
    }

    for(long long i=0; i<m; i++){
      if(jarr[i]==b) indb.push_back(i);
    }

    long long ans = (n-a+m-b);
    if(a == 0 && b==0){
      cout<<ans-1<<"\n";
    }else{
      bool flag = true;
      if(ans != 0 && a != n && b != m)
      for(long long i=0; i<inda.size(); i++){
        for(long long j=0; j<indb.size(); j++){
           { if(str[inda[i]][indb[j]] == '.') ans--; flag = false; break; }
        }
        if(!flag) break;
      }

      cout<<ans<<"\n";
    }
  }
}


#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

//std::vector<pair<long long *, long long *>> v;

int main(int argc, char const *argv[]) {
  long long q;
  cin>>q;
  while(q--){
    long long n, m;
    cin>>n>>m;
    long long iarr[n]={0};
    long long jarr[m]={0};
    char str[n][m];
    for(long long i=0; i<n; i++) {
      for(long long j=0; j<m; j++) {
        char c;
        cin>>c;
        str[i][j]=c;
        if(c == '*'){
          iarr[i]++;
          jarr[j]++;

        }
      }
    }

    long long ans = m+n;
    int cross = m+n;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(str[i][j]=='.'){ ans = min(ans, cross-(iarr[i]+jarr[j]) - 1); }
            else { ans = min(ans, cross-(iarr[i]+jarr[j])); }
        }
    }
     cout<<ans<<"\n";

  }
}


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

//std::vector<pair<long long *, long long *>> v;

int main(int argc, char const *argv[]) {
  long long q;
  cin>>q;
  while(q--){
    long long n, m;
    cin>>n>>m;
    long long iarr[n]={0};
    long long jarr[m]={0};
    char str[n][m];
    for(long long i=0; i<n; i++) {
      for(long long j=0; j<m; j++) {
        char c;
        cin>>c;
        str[i][j]=c;
        if(c == '*'){
          iarr[i]++;
          jarr[j]++;

        }
      }
    }
    std::vector<long long> indb, inda;
    long long a=0, b=0;
    for(long long i=0; i<n; i++){
      if(iarr[i]>=a) a = iarr[i];
    }

    for(long long i=0; i<m; i++){
      if(jarr[i]>=b) b = jarr[i];
    }

    for(long long i=0; i<n; i++){
      if(iarr[i]==a) inda.push_back(i);
    }

    for(long long i=0; i<m; i++){
      if(jarr[i]==b) indb.push_back(i);
    }

    long long ans = (n-a+m-b);
    if(a == 0 && b==0){
      cout<<ans-1<<"\n";
    }else{
      bool flag = true;
      if(ans != 0 && a != n && b != m)
      for(long long i=0; i<inda.size(); i++){
        for(long long j=0; j<indb.size(); j++){

           { if(str[inda[i]][indb[j]] == '.') {ans--; flag = false; break;} }
        }
        if(!flag) break;
      }

      cout<<ans<<"\n";
    }
  }
}


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

//std::vector<pair<int *, int *>> v;

int main(int argc, char const *argv[]) {
  int q;
  cin>>q;
  while(q--){
    int n, m;
    cin>>n>>m;
    int iarr[n]={0};
    int jarr[m]={0};
    char str[n][m];
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
        char c;
        cin>>c;
        str[i][j]=c;
        if(c == '*'){
          iarr[i]++;
          jarr[j]++;

        }
      }
    }
    std::vector<int> indb, inda;
    int a=0, b=0;
    for(int i=0; i<n; i++){
      if(iarr[i]>=a) a = iarr[i];
    }

    for(int i=0; i<m; i++){
      if(jarr[i]>=b) b = jarr[i];
    }

    for(int i=0; i<n; i++){
      if(iarr[i]==a) inda.push_back(i);
    }

    for(int i=0; i<m; i++){
      if(jarr[i]==b) indb.push_back(i);
    }

    long ans = (n-a+m-b);
    bool flag = true;
    if(ans != 0)
    for(int i=0; i<inda.size(); i++){
      for(int j=0; j<indb.size(); j++){
         { if(str[inda[i]][indb[j]] == '.') ans--; flag = false; break; }
      }
      if(!flag) break;
    }

    cout<<ans<<"\n";
  }
}


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

//std::vector<pair<int *, int *>> v;

int main(int argc, char const *argv[]) {
  int q;
  cin>>q;
  while(q--){
    int n, m;
    cin>>n>>m;
    int iarr[n]={0};
    int jarr[m]={0};
    char str[n][m];
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
        char c;
        cin>>c;
        str[i][j]=c;
        if(c == '*'){
          iarr[i]++;
          jarr[j]++;

        }
      }
    }
    std::vector<int> indb, inda;
    int a=0, b=0;
    for(int i=0; i<n; i++){
      if(iarr[i]>=a) a = iarr[i];
    }

    for(int i=0; i<m; i++){
      if(jarr[i]>=b) b = jarr[i];
    }

    for(int i=0; i<n; i++){
      if(iarr[i]==a) inda.push_back(i);
    }

    for(int i=0; i<m; i++){
      if(jarr[i]==b) indb.push_back(i);
    }

    long ans = (n-a+m-b);
    bool flag = true;
    if(ans != 0 && a != n && b != m)
    for(int i=0; i<inda.size(); i++){
      for(int j=0; j<indb.size(); j++){
         { if(str[inda[i]][indb[j]] == '.') ans--; flag = false; break; }
      }
      if(!flag) break;
    }

    cout<<ans<<"\n";
  }
}


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

//std::vector<pair<int *, int *>> v;

int main(int argc, char const *argv[]) {
  int q;
  cin>>q;
  while(q--){
    int n, m;
    cin>>n>>m;
    int iarr[n]={0};
    int jarr[m]={0};
    char str[n][m];
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
        char c;
        cin>>c;
        str[i][j]=c;
        if(c == '*'){
          iarr[i]++;
          jarr[j]++;

        }
      }
    }

    int a=0, b=0, inda, indb;
    for(int i=0; i<n; i++){
      if(iarr[i]>a) a = iarr[i], inda = i;
    }

    for(int i=0; i<m; i++){
      if(jarr[i]>b) b = jarr[i], indb=i;
    }

    long ans = (n-a+m-b);
    if(str[inda][indb] == '.') ans--;

    cout<<ans<<"\n";
  }
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define fori(iter,n)	for(ll iter=0;iter<n;++iter)
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef vector<ll> vll;
typedef bool B;
const ll INF=1e18;

int count(string s, char c)
{
    // Count variable
    int res = 0;

    for (int i=0;i<s.length();i++)

        // checking character in string
        if (s[i] == c)
            res++;

    return res;
}

int main()
{
    IOS;
    ll t; cin>>t;
    ll flag=0;
    while(t--)
    {
        ll n,m,g=0;
        ll ans=0;
        vll v;
        cin>>n>>m;
        ll k=0;
        ll b[m]={};
        ll p=n;
        while(p--)
        {
            string s;
            cin>>s;
            rep(i,0,m)
            {
                if(s[i]=='*')
                b[i]++;
            }
            k=count(s,'*');
            g=max(k,g);
        }

        ans+=(n-*max_element(b,b+m));
        //cout<<ans<<endl;
        cout<<ans+m-g<<endl;
        //cout<<*max_element(b,b+m)<<endl;
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define fori(iter,n)	for(ll iter=0;iter<n;++iter)
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef vector<ll> vll;
typedef bool B;
const ll INF=1e18;

int count(string s, char c)
{
    // Count variable
    int res = 0;

    for (int i=0;i<s.length();i++)

        // checking character in string
        if (s[i] == c)
            res++;

    return res;
}

int main()
{
    IOS;
    ll t; cin>>t;
    ll flag=0;
    while(t--)
    {
        ll n,m,g=0;
        map<ll,string> mp;
        ll ans=0;
        vll v;
        cin>>n>>m;
        ll k=0,h;
        ll b[m]={};
        ll p=n,y;
        while(p--)
        {
            string s;
            cin>>s;
            rep(i,0,m)
            {
                if(s[i]=='*')
                b[i]++;
            }
            k=count(s,'*');
            g=max(k,g);
            if(k==g)
            {
                rep(i,0,m)
                {if(s[i]!='*')
                mp[n-p-1]+=i;}
                y=n-p-1;
            }
        }
        ll j;
        rep(i,0,m)
        {
            if(b[i]==*max_element(b,b+m))
            {j=i; break;}
        }
        B flag=0;
        for(auto x:mp[y])
        {
            if(x==j)
            flag=1;
        }
        ans+=(n-*max_element(b,b+m));
        if(flag)
        ans-=1;
       // cout<<y<<endl;
        cout<<ans+m-g<<endl;
        //cout<<*max_element(b,b+m)<<endl;
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define fori(iter,n)	for( iter=0;iter<n;++iter)
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef int ll;
typedef vector<ll> vll;
typedef bool B;
const ll INF=1e18;

int main()
{
    IOS;
    ll t; cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        vector<string> s(n);
        rep(i,0,n)
            cin>>s[i];
        vll c1(n),c2(n);
        rep(i,0,n)
        {
            rep(j,0,m)
            {
                c1[i]+=(s[i][j]=='.');
                c2[j]+=(s[i][j]=='.');
            }
        }
        ll ans=n+m;
        rep(i,0,n){
        rep(j,0,m)
        {
            ans=min(ans,c1[i]+c2[j] -(s[i][j]=='.'));
        }}
        cout<<ans<<'\n';
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define fori(iter,n)	for(ll iter=0;iter<n;++iter)
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef vector<ll> vll;
typedef bool B;
const ll INF=1e18;

int count(string s, char c)
{
    // Count variable
    int res = 0;

    for (int i=0;i<s.length();i++)

        // checking character in string
        if (s[i] == c)
            res++;

    return res;
}

int main()
{
    IOS;
    ll t; cin>>t;
    ll flag=0;
    while(t--)
    {
        ll n,m,g=0;
        map<ll,string> mp;
        ll ans=0;
        vll v;
        cin>>n>>m;
        ll k=0,h;
        ll b[m]={};
        ll p=n,y;
        while(p--)
        {
            string s;
            cin>>s;
            rep(i,0,m)
            {
                if(s[i]=='*')
                b[i]++;
            }
            k=count(s,'*');
            g=max(k,g);
            if(k==g)
            {
                rep(i,0,m)
                {if(s[i]!='*')
                mp[n-p]+=i;}
                y=n-p;
            }
        }
        ll j;
        rep(i,0,m)
        {
            if(b[i]==*max_element(b,b+m))
            {j=i; break;}
        }
        B flag=0;
        for(auto x:mp[y])
        {
            if(x==j)
            flag=1;
        }
        ans+=(n-*max_element(b,b+m));
        if(flag)
        ans-=1;
        //cout<<g<<endl;
        cout<<ans+m-g<<endl;
        //cout<<*max_element(b,b+m)<<endl;
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define fori(iter,n)	for(ll iter=0;iter<n;++iter)
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef vector<ll> vll;
typedef bool B;
const ll INF=1e18;

int main()
{
    ll t; cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        vector<string> s(n);
        rep(i,0,n)
            cin>>s[i];
        vector<ll> c1(n),c2(n);
        rep(i,0,n)
        {
            rep(j,0,m)
            {
                c1[i]+=(s[i][j]=='.');
                c2[j]+=(s[i][j]=='.');
            }
        }
        ll ans=n+m;
        rep(i,0,n){
        rep(j,0,m)
        {
            ans=min(ans,c1[i]+c2[j] -(s[i][j]=='.'));
        }}
        cout<<ans<<'\n';
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define fori(iter,n)	for( iter=0;iter<n;++iter)
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef int ll;
typedef vector<ll> vll;
typedef bool B;
const ll INF=1e18;

int main()
{
    IOS;
    ll t; cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        vector<string> s(n);
        rep(i,0,n)
            cin>>s[i];
        vll c1(n),c2(m);
        rep(i,0,n)
        {
            rep(j,0,m)
            {
                c1[i]+=(s[i][j]=='.');
                c2[j]+=(s[i][j]=='.');
            }
        }
        ll ans=n+m;
        rep(i,0,n){
        rep(j,0,m)
        {
            ans=min(ans,c1[i]+c2[j] -(s[i][j]=='.'));
        }}
        cout<<ans<<'\n';
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define fori(iter,n)	for(ll iter=0;iter<n;++iter)
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef vector<ll> vll;
typedef bool B;
const ll INF=1e18;

int main()
{
    IOS;
    ll t;
    cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        vector<string> s(n);
        rep(i,0,n)
            cin>>s[i];
        vll a(n),b(m);
        rep(i,0,n)
            rep(j,0,m)
                {
                    if(s[i][j]=='*')
                    {
                        a[i]++;
                        b[j]++;
                    }
                }
        ll ans=INF;
        rep(i,0,n)
            rep(j,0,m)
            ans=min(ans,n+m-a[i]-b[j]-((s[i][j]=='*')? 0:1));
        cout<<ans<<'\n';
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<n; i++)
#define PV(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PM(m) FORN(j,0,m.size()) {PV(m[j]);}
#define fi first
#define se second
#define p_b push_back
#define pp_b pop_back
#define mk_p make_pair
#define pr_setp(n)cout<<setprecision(2)<<n;
#define pr_setp1(n) cout<<setprecision(8)<<fixed<<n;
#define l_b lower_bound
#define u_b upper_bound
#define MAXP 1500000000000000000
typedef long long ll;
vector<ll>primes;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin>>q;
	while(q--)
	{
		int n,m;
		cin>>n>>m;
		int ans1(0),ans2(0);
		vector<vector<char>>nb(n,vector<char>(m));
		int ix(0);
		for(int i=0;i<n;++i)
		{
			int a(0);
			for(int j=0;j<m;++j)
			{
				cin>>nb[i][j];
				if(nb[i][j]=='*')++a;
			}
			if(ans1<a)
			{
				ans1=a;
				ix=i;
			}
		//	ans1=max(ans1,a);
		}
		bool s(0);
		for(int i=0;i<m;++i)
		{
			int a(0);
			for(int j=0;j<n;++j)
			{
			//	cin>>nb[i][j];
				if(nb[j][i]=='*')++a;
			}
			if((ans2-(nb[ix][i]=='*'))<a)
			{
				ans2=a;
				ans2-=(nb[ix][i]=='*');
			}

		}
		cout<<(n+m-1)-(ans1+ans2)<<endl;

	}
	return 0;
}


#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<n; i++)
#define PV(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PM(m) FORN(j,0,m.size()) {PV(m[j]);}
#define fi first
#define se second
#define p_b push_back
#define pp_b pop_back
#define mk_p make_pair
#define pr_setp(n)cout<<setprecision(2)<<n;
#define pr_setp1(n) cout<<setprecision(8)<<fixed<<n;
#define l_b lower_bound
#define u_b upper_bound
#define MAXP 1500000000000000000
typedef long long ll;
vector<ll>primes;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin>>q;
	while(q--)
	{
		int n,m;
		cin>>n>>m;
		int ans1(0),ans2(0);
		vector<vector<char>>nb(n,vector<char>(m));
		int ix(0);
		for(int i=0;i<n;++i)
		{
			int a(0);
			for(int j=0;j<m;++j)
			{
				cin>>nb[i][j];
				if(nb[i][j]=='*')++a;
			}
			if(ans1<a)
			{
				ans1=a;
				ix=i;
			}
		//	ans1=max(ans1,a);
		}
		bool s(0);
		for(int i=0;i<m;++i)
		{
			int a(0);
			for(int j=0;j<n;++j)
			{
			//	cin>>nb[i][j];
				if(nb[j][i]=='*')++a;
			}
			if(ans2<a)
			{
				ans2=a;
				ans2+=(nb[ix][i]=='.');
			}

		}
		int r=s?1:0;
		cout<<(n+m-1)-(ans1+ans2-1)<<endl;

	}
	return 0;
}


#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<n; i++)
#define PV(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PM(m) FORN(j,0,m.size()) {PV(m[j]);}
#define fi first
#define se second
#define p_b push_back
#define pp_b pop_back
#define mk_p make_pair
#define pr_setp(n)cout<<setprecision(2)<<n;
#define pr_setp1(n) cout<<setprecision(8)<<fixed<<n;
#define l_b lower_bound
#define u_b upper_bound
#define MAXP 1500000000000000000
typedef long long ll;
typedef vector<int> vi;
vector<ll>primes;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin>>q;
	while(q--)
	{
		int n,m;
		cin>>n>>m;
		int ans1(0),ans2(0);
		vector<vector<char>>nb(n,vector<char>(m));
		vi x(m),y(n);
		FORN(i,0,n){
		    FORN(j,0,m){
		        cin>>nb[i][j];
		        if(nb[i][j]=='*'){
		            ++x[j];
		            ++y[i];
		        }
		    }
		}
		int maxi=0;
		FORN(i,0,n){
		    FORN(j,0,m){
		        maxi=max(maxi,(x[j]+y[i]-(nb[i][j]=='*')));
		    }
		}
		cout<<(n+m-1)-(maxi)<<endl;

	}
	return 0;
}