#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	int a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	int *f = new int [n+1];
	char *a = new char [n+1];
	int *back = new int [n+1];
	for (int i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (int i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (int i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	int ans = INT_MIN;
	for (int i = 0;i < n;i++)
	{
		int l = 1;
		int r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		int m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (r - l > 1)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=INT_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	int a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	int *f = new int [n+1];
	char *a = new char [n+1];
	int *back = new int [n+1];
	for (int i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (int i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (int i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	int ans = INT_MIN;
	for (int i = 0;i < n;i++)
	{
		int l = 1;
		int r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		g = f[i] + a1 * (i - 1);
		//else
		//	g = 0;
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		int m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l+r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) ans = i + l + 1;
		else if (!k && ((i + l) > ans)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=INT_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	for (ll  i = 1;i <= n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		//if (i > 0)
		g = back[i] + a1 * i + f[0];
		//else
		//g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (back[i]<=T && i + 1 > ans) {ans = i + 1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && back[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (f[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (r - l > 1)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	for (ll  i = 1;i < n;i++)
	{
		f[i]-=f[0];
	}
	for (ll  i = 1;i <= n;i++)
	{
		ll  l = 0;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		//if (i > 0)
		g = back[i] + a1 * i + f[0];
		//else
		//g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if ((back[i] + f[0]) <= T && i + 1 > ans) {ans = i + 1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && (back[i] + f[0]) <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (f[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l+1) > ans) && (g + f[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g + f[l - 1]<=T)) ans = i + l;
		if (k && (i + m+1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l <= r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (i+1 > ans && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	for (ll  i = 1;i < n;i++)
	{
		f[i]-=f[0];
	}
	for (ll  i = 1;i < n;i++)
	{
		ll  l = 0;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		//if (i > 0)
		g = back[i] + a1 * i + f[0];
		//else
		//g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if ((back[i] + f[0]) <= T && i + 1 > ans) {ans = i + 1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l >= r) {if (i+1 > ans && (back[i] + f[0]) <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (f[m] + g < T)
			{
				l = m + 1;
			}
			else if (f[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g + f[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g + f[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	int a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	int *f = new int [n+1];
	char *a = new char [n+1];
	int *back = new int [n+1];
	for (int i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (int i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (int i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	int ans = INT_MIN;
	for (int i = 0;i < n;i++)
	{
		int l = 1;
		int r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		g = f[i] + a1 * i;
		//else
		//	g = 0;
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		int m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l+r)/2;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) ans = i + l + 1;
		else if (!k && ((i + l) > ans)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=INT_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (i+1 > ans && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	for (ll  i = 1;i < n;i++)
	{
		f[i]-=f[0];
	}
	for (ll  i = 1;i < n;i++)
	{
		ll  l = 0;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		//if (i > 0)
		g = back[i] + a1 * i + f[0];
		//else
		//g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if ((back[i] + f[0]) <= T && i + 1 > ans) {ans = i + 1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (i+1 > ans && (back[i] + f[0]) <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (f[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l+1) > ans) && (g + f[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g + f[l - 1]<=T)) ans = i + l;
		if (k && (i + m+1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	for (ll  i = 1;i < n;i++)
	{
		f[i]-=f[0];
	}
	for (ll  i = 1;i < n;i++)
	{
		ll  l = 0;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		//if (i > 0)
		g = back[i] + a1 * i + f[0];
		//else
		//g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if ((back[i] + f[0]) <= T && i + 1 > ans) {ans = i + 1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && (back[i] + f[0]) <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (f[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l+1) > ans) && (g + f[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g + f[l - 1]<=T)) ans = i + l;
		if (k && (i + m+1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	int a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	int *f = new int [n];
	char *a = new char [n];
	int *back = new int [n];
	for (int i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (int i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (int i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	int ans = INT_MIN;
	for (int i = 0;i < n;i++)
	{
		int l = 1;
		int r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		g = f[i] + a1 * i;
		//else
		//	g = 0;
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		int m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l+r)/2;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) ans = i + l + 1;
		else if (!k && ((i + l) > ans)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=INT_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	int a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	int *f = new int [n+1];
	char *a = new char [n+1];
	int *back = new int [n+1];
	for (int i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (int i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (int i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	int ans = INT_MIN;
	for (int i = 0;i < n;i++)
	{
		int l = 1;
		int r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		int m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (r - l > 1)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=INT_MIN)
	cout<<ans;
	else
	cout<<0;
	system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (i+1 > ans && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	for (ll  i = 1;i < n;i++)
	{
		f[i]-=f[0];
	}
	for (ll  i = 1;i < n;i++)
	{
		ll  l = 0;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		//if (i > 0)
		g = back[i] + a1 * i + f[0];
		//else
		//g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if ((back[i] + f[0]) <= T && i + 1 > ans) {ans = i + 1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l >= r) {if (i+1 > ans && (back[i] + f[0]) <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (f[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l+1) > ans) && (g + f[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g + f[l - 1]<=T)) ans = i + l;
		if (k && (i + m+1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;

int  main ()
{
	ll  a1,b1,n,T;
	cin>>n>>a1>>b1>>T;
	ll  *f = new ll  [n+1];
	char *a = new char [n+1];
	ll  *back = new ll  [n+1];
	for (ll  i = 0;i<n;i++) cin>>a[i];
	//f[0] = ((a[0]=='w')?(b1+a1):a1);
	f[0] = 1 + ((a[0]=='w')?b1:0);
	back[0] = 0;
	for (ll  i = 1;i<n;i++)
	{
		f[i] = f[i - 1] + ((a[i]=='w')?(b1+a1+1):a1+1);
	}
	for (ll  i = 1;i<=n;i++)
	{
		back[i] = back[i - 1] + ((a[n - i]=='w')?(b1+a1+1):(a1+1));
	}
	ll  ans = LLONG_MIN;
	for (ll  i = 0;i < n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		if (i > 0)
		g = f[i] + a1 * i;
		else
		g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if (f[i]<=T && i+1>ans) {ans = i+1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && f[i] <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (back[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l + 1) > ans) && (g+back[l]<=T)) {ans = i + l + 1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m + 1) > ans)
		{
			ans = i + m + 1;
		}
		//cout<<ans<<endl;
	}
	for (ll  i = 1;i <= n;i++)
	{
		ll  l = 1;
		ll  r = n - i - 1;
		ll g;
		//if (i - 1 >= 0)
		//if (i > 0)
		g = back[i] + a1 * i + f[0];
		//else
		//g = f[i];
		//cout<<f[i]<<endl;
		if (g >= T) {if ((back[i] + f[0]) <= T && i + 1 > ans) {ans = i + 1;}continue;}
		//if (g == T) {if (ans > i) ans = i; continue;}
		ll  m = 0;
		//if (back[1] + g > T) {continue;}
		//if (back[1] + g == T) {if (i+1>ans) ans = i+1;continue;}
		if (l > r) {if (ans > i + 1 && (back[i] + f[0]) <= T) ans = i + 1;continue;}
		bool k = false;
		//cout<<l<<" "<<r<<endl;
		while (l < r)
		{
			m = (l + r)/2;
			//cout<<m<<" "<<f[i]<<" "<<g<<" "<<back[m] + g<<endl;
			if (f[m] + g < T)
			{
				l = m + 1;
			}
			else if (back[m] + g > T)
			{
				r = m - 1;
			}
			else {k =true;break;}
			//cout<<i<<" "<<l<<" "<<r<<" "<<back[l]<<endl;
		}
		//cout<<i<<" "<<l<<" "<<r<<endl;
		//cout<<i<<" "<<l<<endl;
		if (!k && ((i + l+1) > ans) && (g+back[l]<=T)) {ans = i + l+1;continue;}
		if (!k && ((i + l) > ans) && (g+back[l - 1]<=T)) ans = i + l;
		if (k && (i + m+1) > ans)
		{
			ans = i + m+1;
		}
		//cout<<ans<<endl;
	}
	if (ans!=LLONG_MIN)
	cout<<ans;
	else
	cout<<0;
	//system("pause");
	return 0;
}


#include <iostream>
typedef long long ll;

using namespace std;
const int SZ = 100100;
int n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = (buf[0] == 'w') ? b : 1;
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i-1] + ((buf[i] == 'w') ? b : 1);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + ((buf[i] == 'w') ? b : 1);
	}
	if (T < pr[0]) {
		cout << 0;
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n;
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}
	cout << res;
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	if(j == 0) return T >= i*a + pr[i];
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l < n && rOk(i, l + 1)) return i+l+2;
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	if (j == 0) return T >= i*a + pl[n - i];
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l < n && lOk(i, l + 1)) return i+l+1;
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l == n) return 0;
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l == n) return 0;
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 100100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << pr[0] << pr[1] << pr[2] << pr[3] << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << pl[n] << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	if(j == 0) return T >= i*a + pr[i];
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

bool lOk(int i, int j) {
	if (j == 0) return T >= i*a + pl[n - i] + pr[0];
	return T >= (2 * i + j - 1)*a + pl[n - i] + pr[j - 1];
}

int bin(int i, bool (f)(int,int)) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (f(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (f(i, l)) return i + l + 1;
	if (l > 0 && f(i, l - 1)) return i + l;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = bin(i, rOk);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = bin(i, lOk);
		if (cur > res) res = cur;
	}
	cout << res << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;

using namespace std;
const int SZ = 100100;
int n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}
	cout << res << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 100100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l == n) return 0;
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l == n) return 0;
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << pl[0] << pr[n-1] << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	if(j == 0) return T >= i*a + pr[i];
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	if (j == 0) return T >= i*a + pl[n - i] + pr[0];
	return T >= (2 * i + j - 1)*a + pl[n - i] + pr[j-1];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}
	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	if(j == 0) return T >= i*a + pr[i];
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	if (j == 0) return T >= i*a + pl[n - i] + +pr[0];
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << lBin(2) << lBin(3) << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;

using namespace std;
const int SZ = 100100;
int n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << 2 << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	if (j == 0) return T >= i*a + pr[i];
	return T >= (2 * i + j)*a + pr[i] + pl[n - j];
}

bool lOk(int i, int j) {
	if (j == 0) return T >= i*a + pl[n - i] + pr[0];
	return T >= (2 * i + j - 1)*a + pl[n - i] + pr[j - 1];
}

int bin(int i, bool (f)(int, int)) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (f(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (f(i, l)) return i + l;
	if (l > 0 && f(i, l - 1)) return i + l - 1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b + 1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n - 1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n - 1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = bin(i, rOk) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = bin(i, lOk);
		if (cur > res) res = cur;
	}
	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
	return 0;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>
typedef long long ll;
using namespace std;
const int SZ = 500100;
ll n, a, b, T;
ll pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l < n && rOk(i, l + 1)) return i+l+2;
	if (rOk(i, l)) return i+l+1;
	if (l > 0 && rOk(i, l - 1)) return i+l;
	return 0;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (l < n && lOk(i, l + 1)) return i+l+1;
	if (lOk(i, l)) return i+l;
	if (l > 0 && lOk(i, l - 1)) return i+l-1;
	return 0;
}

int getVal(char c) {
	if (c == 'w') return b+1;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i);
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0; int r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << lBin(0) << lBin(1) << "\n";
	return 0;
}


#include <iostream>

using namespace std;
const int SZ = 100100;
int n, a, b, T;
int pr[SZ], pl[SZ];
char buf[SZ];

bool rOk(int i, int j) {
	return T >= (2 * i + j)*a + pr[i] + pl[n-j];
}

int lBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (rOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (rOk(i, l)) return l;
	if (l > 0 && rOk(i, l - 1)) return l - 1;
}

bool lOk(int i, int j) {
	return T >= (2 * i + j)*a + pl[n - i] + pr[j];
}

int rBin(int i) {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (lOk(i, mid)) {
			l = mid + 1;
		}
		else {
			r = mid;
		}
	}
	if (lOk(i, l)) return l;
	if (l > 0 && lOk(i, l - 1)) return l - 1;
}

int getVal(char c) {
	if (c == 'w') return b;
	return 1;
}

int main() {
	char ch;
	cin >> n >> a >> b >> T >> buf;
	pr[0] = getVal(buf[0]);
	for (int i = 1; i < n; i++) {
		pr[i] = pr[i - 1] + getVal(buf[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		pl[i] = pl[i + 1] + getVal(buf[i]);
	}
	if (T < pr[0]) {
		cout << "0\n";
		return 0;
	}
	if (T >= pr[n - 1] + a*(n-1)) {
		cout << n << "\n";
		return 0;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int cur = lBin(i) + 1;
		if (cur > res) res = cur;
	}

	for (int i = 1; i < n; i++) {
		int cur = rBin(i);
		if (cur > res) res = cur;
	}

	cout << res << "\n";
	return 0;
}


 def main():
    n, a, b, t = map(int, input().split())
    b += 1
    l = [b if char == "w" else 1 for char in input()]
    t -= sum(l) - a * (n + 2)
    hi, n2 = n, n * 2
    n21 = n2 + 1
    lo = res = 0
    l *= 2
    while lo <= n and hi < n2:
        t -= l[hi]
        hi += 1
        b = hi - n
        while lo < b or (hi - lo + min(hi, n21 - lo)) * a > t:
            t += l[lo]
            lo += 1
        if res < hi - lo:
            res = hi - lo
            if res == n:
                break
    print(res)

if __name__ == '__main__':
    main()


n, a, b, t = map(int, input().split())
  b += 1
  l = [b if char == "w" else 1 for char in input()]
  t -= sum(l) - a * (n + 2)
  hi, n2 = n, n * 2
  n21 = n2 + 1
  lo = res = 0
  l *= 2
  while lo <= n and hi < n2:
    t -= l[hi]
    hi += 1
    b = hi - n
    while lo < b or (hi - lo + min(hi, n21 - lo)) * a > t:
      t += l[lo]
      lo += 1
    if res < hi - lo:
      res = hi - lo
      if res == n:
        break
print(res)


n, a, b, t = map(int, input().split())
b += 1
l = [b if char == "w" else 1 for char in input()]
t -= sum(l) - a * (n + 2)
hi, n2 = n, n * 2
n21 = n2 + 1
lo = res = 0
l *= 2
while lo <= n and hi < n2:
  t -= l[hi]
  hi += 1
  b = hi - n
  while lo < b or (hi - lo + min(hi, n21 - lo)) * a > t:
    t += l[lo]
    lo += 1
  if res < hi - lo:
    res = hi - lo
    if res == n:
      break
print(res)


def main():
    n, a, b, t = map(int, input().split())
    b += 1
    l = [b if char == "w" else 1 for char in input()]
    t -= sum(l) - a * (n + 2)
    hi, n2 = n, n * 2
    n21 = n2 + 1
    lo = res = 0
    l *= 2
    while lo <= n and hi < n2:
        t -= l[hi]
        hi += 1
        b = hi - n
        while lo < b or (hi - lo + min(hi, n21 - lo)) * a > t:
            t += l[lo]
            lo += 1
        if res < hi - lo:
            res = hi - lo
            if res == n:
                break
    print(res)

if __name__ == '__main__':
    main()


#include <bits/stdc++.h>

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 2e5;
const int INF = (int) 1e9 + 7;

int cnt[N + 7];

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int n, k;
	sf("%d %d", &n, &k);
	for (int i = 0; i < n; ++i) {
		int x;
		sf("%d", &x);
		++cnt[x];
	}
	vector<int> v;
	for (int i = 1; i <= N; ++i) {
		if (cnt[i] > 0) {
			v.pp(i);
		}
	}

	sort(v.begin(), v.end());

	int l = 1, r = n / k;
	while (l < r) {
		int mid = (l + r + 1) / 2;

		int m = k;
		for (int i = 0; i < v.size(); ++i) {
			m -= cnt[v[i]] / mid;
		}

		if (m < 1) l = mid;
		else r = mid - 1;
	}

	for (int i = 0; i < v.size(); ++i) {
		int x = min(cnt[v[i]] / l, k);
		for (int j = 0; j < x; ++j) {
			printf("%d ", v[i]);
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 struct node
 {
     int n,f;
 };
 bool rule(node a,node b)
 {
     return a.f > b.f;
 }
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    map<int,int> m;
    f(n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    vector<node> v;
    for(auto it : m)
    {
        node s;
        s.n = it.ff;
        s.f = it.ss;
        v.pb(s);
    }
    sort(v.begin(),v.end(),rule);
    vi ans;
    int lst = k-1;
    int i = 0;
    bool full = false;
    while(1)
    {
        int x = 2;
        while(v[i].f >= x * v[lst].f)
        {
            lst --;
            x++;
        }
        for(int j =0;j<x-1;j++)
        {
            ans.pb(v[i].n);
            if(ans.size()==k)
            {
                full = 1; break;
            }
        }
        if(full)break;
        i++;
    }
    f(ans.size())cout << ans[i] << " ";

    return 0;
 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 struct node
 {
     int n,f;
 };
 bool rule(node a,node b)
 {
     return a.f > b.f;
 }
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    map<int,int> m;
    f(n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    vector<node> v;
    for(auto it : m)
    {
        node s;
        s.n = it.ff;
        s.f = it.ss;
        v.pb(s);
    }
    sort(v.begin(),v.end(),rule);
    vi ans;
    int lst =min( k-1,int(v.size()-1));
    int i = 0;
    bool full = false;
    while(1)
    {
        int x = 2;
        while(v[i].f >= x * v[lst].f)
        {
            lst --;
            x++;
        }
        if(lst == i)
        {
            while(1)
            {
                ans.pb(v[i].n);
                if(ans.size()==k)
                {
                    full = 1;break;
                }
            }
        }
        if(full)break;
        for(int j =0;j<x-1;j++)
        {
            ans.pb(v[i].n);
            if(ans.size()==k)
            {
                full = 1; break;
            }
        }
        if(full)break;
        i++;
    }
    f(ans.size())cout << ans[i] << " ";

    return 0;
 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 struct node
 {
     int n,f;
 };
 bool rule(node a,node b)
 {
     return a.f > b.f;
 }
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    map<int,int> m;
    f(n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    vector<node> v;
    for(auto it : m)
    {
        node s;
        s.n = it.ff;
        s.f = it.ss;
        v.pb(s);
    }
    sort(v.begin(),v.end(),rule);
    vi ans;
    int lst =min( k-1,int(v.size()-1));
    int i = 0;
    bool full = false;
    while(1)
    {
        int x = 2;
        while(v[i].f >= x * v[lst].f)
        {
            lst --;
            x++;
        }
     /*   if(lst == i)
        {
            while(1)
            {
                ans.pb(v[i].n);
                if(ans.size()==k)
                {
                    full = 1;break;
                }
            }
        }
        if(full)break;*/
        for(int j =0;j<x-1;j++)
        {
            ans.pb(v[i].n);
            if(ans.size()==k)
            {
                full = 1; break;
            }
        }
        if(full)break;
        i++;
    }
    f(ans.size())cout << ans[i] << " ";

    return 0;
 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 struct node
 {
     int n,f;
 };
 bool rule(node a,node b)
 {
     return a.f > b.f;
 }
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    map<int,int> m;
    f(n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    vector<node> v;
    for(auto it : m)
    {
        node s;
        s.n = it.ff;
        s.f = it.ss;
        v.pb(s);
    }
    sort(v.begin(),v.end(),rule);
    vi ans;
    int lst =min( k-1,int(v.size()-1));
    int i = 0;
    bool full = false;
    while(1)
    {
        int x = 2;
        if(i==lst)
        {
             while(1)
            {
                ans.pb(v[i].n);
                if(ans.size()==k)
                {
                    full = 1;break;
                }
            }
             if(full)break;
        }
        while(v[i].f >= x * v[lst].f)
        {
            lst --;
            x++;
        }
        for(int j =0;j<x-1;j++)
        {
            ans.pb(v[i].n);
            if(ans.size()==k)
            {
                full = 1; break;
            }
        }
        if(full)break;
        i++;
    }
    f(ans.size())cout << ans[i] << " ";

    return 0;
 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 struct node
 {
     int n,f;
 };
 bool rule(node a,node b)
 {
     return a.f > b.f;
 }
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    map<int,int> m;
    f(n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    vector<node> v;
    for(auto it : m)
    {
        node s;
        s.n = it.ff;
        s.f = it.ss;
        v.pb(s);
    }
    sort(v.begin(),v.end(),rule);
    vi ans;
    int lst =min( k-1,int(v.size()-1));
    int i = 0;
    bool full = false;
    while(1)
    {
        int x = 2;
        if(i>=v.size())break;
        while(v[i].f >= x * v[lst].f)
        {
            lst --;
            x++;
        }
        for(int j =0;j<x-1;j++)
        {
            ans.pb(v[i].n);
            if(ans.size()==k)
            {
                full = 1; break;
            }
        }
        if(full)break;
        i++;
    }
    f(ans.size())cout << ans[i] << " ";

    return 0;
 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 struct node
 {
     int n,f;
 };
 bool rule(node a,node b)
 {
     return a.f > b.f;
 }
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    map<int,int> m;
    f(n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    vector<node> v;
    for(auto it : m)
    {
        node s;
        s.n = it.ff;
        s.f = it.ss;
        v.pb(s);
    }
    sort(v.begin(),v.end(),rule);
    vi ans;
    int lst =min( k-1,int(v.size()-1));
    int i = 0;
    bool full = false;
    if(lst == i)
    {
        f(k)ans.pb(v[0].n);
    }
    while(1)
    {
        int x = 2;
        if(i>=v.size())break;
        while(v[i].f >= x * v[lst].f)
        {
            lst --;
            x++;
        }
        for(int j =0;j<x-1;j++)
        {
            ans.pb(v[i].n);
            if(ans.size()==k)
            {
                full = 1; break;
            }
        }
        if(full)break;
        i++;
    }
    f(ans.size())cout << ans[i] << " ";

    return 0;
 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ul>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
//#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
int freq[MAX_];
int n,k;
vector<int> t;  // answer

bool check(int val)    // some value sum over all MAX_ freq / val
{
    t.clear();
    for(int i =0;i<MAX_;i++)
    {
        int ex = min(freq[i]/val , k - (int)t.size());   // including an integer . and also maintain the size of t.
        while(ex--)t.pb(i);
    }
    if(t.size() == k)return 1;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    vi arr(n);
    memset(freq,0 , sizeof(freq));
    f(n)
    {
        cin>>arr[i];
        freq[arr[i]]++;
    }
    // binary search
    int l = 0,r = n;
    while(r -l > 1)
    {
        int mid=  (l+r)/2;
        if(check(mid))
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }
    if(check(r) == false)
    {
        check(l);
    }
    display(t);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 struct node
 {
     int n,f;
 };
 bool rule(node a,node b)
 {
     return a.f > b.f;
 }
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    map<int,int> m;
    f(n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    vector<node> v;
    for(auto it : m)
    {
        node s;
        s.n = it.ff;
        s.f = it.ss;
        v.pb(s);
    }
    sort(v.begin(),v.end(),rule);
    vi ans;
    int lst =min( k-1,int(v.size()-1));
    int i = 0;
    bool full = false;
    if(lst == i)
    {
        f(k)ans.pb(v[0].n);
    }
    else{
    while(1)
    {
        int x = 2;
        if(i>=v.size())break;
        while(v[i].f >= x * v[lst].f)
        {
            lst --;
            x++;
        }
        for(int j =0;j<x-1;j++)
        {
            ans.pb(v[i].n);
            if(ans.size()==k)
            {
                full = 1; break;
            }
        }
        if(full)break;
        i++;
    }
    }
    f(ans.size())cout << ans[i] << " ";

    return 0;
 }


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

int a[200005];

int main() {
multimap<int,int, greater<int> > k1;
map<int,int>k2;
int n,k;
cin>>n>>k;
int temp;
for(int i=0;i<n;i++){
cin>>temp;
a[temp]++;

}
for(int i=0;i<200005;i++){
  if(a[i]>0){
    k2[i]=a[i];
  }
}
auto x1=k2.begin();

while(x1!=k2.end()){
 k1.insert ( std::pair<int,int>(x1->second,x1->first) );

  x1++;
}

auto x2=k1.begin();

int count1=0;
vector<int >k3;
vector<int >k4;
int min1=9999999;
bool l=true;
while(count1!=k){
  min1=min(min1,x2->first);
k3.push_back(x2->second);
count1++;
x2++;
}

while(true){
  min1++;
count1=0;
x2=k1.begin();
while(count1<k){
  if(x2==k1.end()){
    l=false;
    break;
  }
int kj=x2->first;
if(kj/min1==0){l=false;break;}
count1+=kj/min1;
for(int i=0;i<kj/min1;i++)k4.push_back(x2->second);
x2++;
}
if(l==true&&count1>=k){
k3=k4;
  continue;
}
else break;

}

for( int i=0;i<k;i++)cout<<k3[i]<<" ";
return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> >a(20005);
bool comp(pair<int,int> p1,pair<int,int>p2){
  return p1.first>p2.first;
}
bool feascheck(int mid,int k){
int temp=0;
int i=0;
while(temp<k&&a[i].first/mid!=0){
temp+=a[i].first/mid;
i++;
}
if(temp<k)return 0;
return 1;

}
int main() {
int n,k;
cin>>n>>k;
vector<int>b(n);
for(int i=0;i<n;i++){
  cin>>b[i];
  a[b[i]].first++;
  a[b[i]].second=b[i];
}
sort(a.begin(),a.end(),comp);
int min1=INT_MAX;
int max1=-1;
int s=1,e=a[0].first;
while(s<e){
  int mid=(s+e)/2;
if(feascheck(mid,k)){
max1=max(max1,mid);
s=mid+1;
}
else e=mid-1;
}
int count1=0;
for(int i=0;i<a.size();i++){
  for(int j=0;j<a[i].first/max1;j++){
    cout<<a[i].second<<" ";
    count1++;
    if(count1==k)break;
  }
  if(count1==k)break;
}
cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> >a(20005);
bool comp(pair<int,int> p1,pair<int,int>p2){
  return p1.first>p2.first;
}
bool feascheck(int mid,int k){
int temp=0;
int i=0;
while(temp<k&&a[i].first/mid!=0){
temp+=a[i].first/mid;
i++;
}
if(temp<k)return 0;
return 1;

}
int main() {
int n,k;
cin>>n>>k;
vector<int>b(n);
for(int i=0;i<n;i++){
  cin>>b[i];
  a[b[i]].first++;
  a[b[i]].second=b[i];
}
sort(a.begin(),a.end(),comp);
int min1=INT_MAX;
int max1=-1;
int s=1,e=a[0].first;
while(s<=e){
  int mid=(s+e)/2;
if(feascheck(mid,k)){
max1=max(max1,mid);
s=mid+1;
}
else e=mid-1;
}

int count1=0;
for(int i=0;i<a.size();i++){
  for(int j=0;j<a[i].first/max1;j++){
    cout<<a[i].second<<" ";
    count1++;
    if(count1==k)break;
  }
  if(count1==k)break;
}
cout<<endl;

}


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

int a[200005];

int main() {
multimap<int,int, greater<int> > k1;
map<int,int>k2;
int n,k;
cin>>n>>k;
int temp;
for(int i=0;i<n;i++){
cin>>temp;
a[temp]++;

}
for(int i=0;i<200005;i++){
  if(a[i]>0){
    k2[i]=a[i];
  }
}
auto x1=k2.begin();

while(x1!=k2.end()){
 k1.insert ( std::pair<int,int>(x1->second,x1->first) );

  x1++;
}

auto x2=k1.begin();

int count1=0;
vector<int >k3;
vector<int >k4;
int min1=9999999;
bool l=true;
while(count1!=k){
  min1=min(min1,x2->first);
k3.push_back(x2->second);
count1++;
x2++;
}

while(true){
  min1++;
count1=0;
x2=k1.begin();
k4.clear();
while(count1<k){
  if(x2==k1.end()){
    l=false;
    break;
  }
int kj=x2->first;
if(kj/min1==0){l=false;break;}
count1+=kj/min1;
for(int i=0;i<kj/min1;i++)k4.push_back(x2->second);
x2++;
}
if(l==true&&count1>=k){
for(int i=0;i<k;i++){
  k3[i]=k4[i];
}
}
else break;

}

for( int i=0;i<k;i++)cout<<k3[i]<<" ";
return 0;
}


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

int a[200005];

int main() {
multimap<int,int, greater<int> > k1;
map<int,int>k2;
int n,k;
cin>>n>>k;
int temp;
for(int i=0;i<n;i++){
cin>>temp;
a[temp]++;

}
for(int i=0;i<200005;i++){
  if(a[i]>0){
    k2[i]=a[i];
  }
}
auto x1=k2.begin();

while(x1!=k2.end()){
 k1.insert ( std::pair<int,int>(x1->second,x1->first) );

  x1++;
}

auto x2=k1.begin();

int count1=0;
vector<int >k3;
vector<int >k4;
int min1=9999999;
bool l=true;
while(count1!=k){
  min1=min(min1,x2->first);
k3.push_back(x2->second);
count1++;
x2++;
}

while(true){
  min1++;
count1=0;
x2=k1.begin();
while(count1<k){
  if(x2==k1.end()){
    l=false;
    break;
  }
int kj=x2->first;
if(kj/min1==0){l=false;break;}
count1+=kj/min1;
for(int i=0;i<kj/min1;i++)k4.push_back(x2->second);
x2++;
}
if(l==true&&count1>=k){
k3=k4;
  continue;
}
else break;

}

for( int i=0;i<k3.size();i++)cout<<k3[i]<<" ";
return 0;
}


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

int a[200005];

int main() {
multimap<int,int, greater<int> > k1;
map<int,int>k2;
int n,k;
cin>>n>>k;
int temp;
for(int i=0;i<n;i++){
cin>>temp;
a[temp]++;

}
for(int i=0;i<200005;i++){
  if(a[i]>0){
    k2[i]=a[i];
  }
}
auto x1=k2.begin();

while(x1!=k2.end()){
 k1.insert ( std::pair<int,int>(x1->second,x1->first) );

  x1++;
}

auto x2=k1.begin();

int count1=0;
vector<int >k3;
vector<int >k4;
int min1=9999999;
bool l=true;
while(count1!=k){
  min1=min(min1,x2->first);
k3.push_back(x2->second);
count1++;
x2++;
}

while(true){
  min1++;
count1=0;
x2=k1.begin();
k4.clear();
while(count1<k){
  if(x2==k1.end()){
    l=false;
    break;
  }
int kj=x2->first;
if(kj/min1==0){l=false;break;}
count1+=kj/min1;
for(int i=0;i<kj/min1;i++)k4.push_back(x2->second);
x2++;
}
if(l==true&&count1>=k){
k3=k4;
  continue;
}
else break;

}

for( int i=0;i<k;i++)cout<<k3[i]<<" ";
return 0;
}


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

int a[200005];

int main() {
multimap<int,int, greater<int> > k1;
map<int,int>k2;
int n,k;
cin>>n>>k;
int temp;
for(int i=0;i<n;i++){
cin>>temp;
a[temp]++;

}
for(int i=0;i<200005;i++){
  if(a[i]>0){
    k2[i]=a[i];
  }
}
auto x1=k2.begin();

while(x1!=k2.end()){
 k1.insert ( std::pair<int,int>(x1->second,x1->first) );

  x1++;
}

auto x2=k1.begin();

int count1=0;
vector<int >k3;
vector<int >k4;
int min1=9999999;
bool l=true;
while(count1!=k){
  min1=min(min1,x2->first);
k3.push_back(x2->second);
count1++;
x2++;
}

while(true){
  min1++;
count1=0;
x2=k1.begin();
k4.clear();
while(count1<k){
  if(x2==k1.end()){
    l=false;
    break;
  }
int kj=x2->first;
count1+=kj/min1;
for(int i=0;i<kj/min1;i++)k4.push_back(x2->second);
x2++;
}
if(l==true&&count1>=k){
for(int i=0;i<k;i++){
  k3[i]=k4[i];
}
}
else break;

}

for( int i=0;i<k;i++)cout<<k3[i]<<" ";
return 0;
}


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

int a[200005];

int main() {
multimap<int,int, greater<int> > k1;
map<int,int>k2;
int n,k;
cin>>n>>k;
int temp;
for(int i=0;i<n;i++){
cin>>temp;
a[temp]++;

}
for(int i=0;i<200005;i++){
  if(a[i]>0){
    k2[i]=a[i];
  }
}
auto x1=k2.begin();

while(x1!=k2.end()){
 k1.insert ( std::pair<int,int>(x1->second,x1->first) );

  x1++;
}

auto x2=k1.begin();

int count1=0;
vector<int >k3;
vector<int >k4;
int min1=9999999;
bool l=true;
while(count1!=k){
  min1=min(min1,x2->first);
k3.push_back(x2->second);
count1++;
x2++;
}

while(true){
  min1++;
count1=0;
x2=k1.begin();
while(count1<k){
  if(x2==k1.end()){
    l=false;
    break;
  }
int kj=x2->first;
if(kj/min1==0){l=false;break;}
count1+=kj/min1;
for(int i=0;i<kj/min1;i++)k4.push_back(x2->second);
x2++;
}
if(l==true&&count1>=k){
k3=k4;
  continue;
}
else break;

}

for( auto y: k3)cout<<y<<" ";
return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> >a(200005);
bool comp(pair<int,int> p1,pair<int,int>p2){
  return p1.first>p2.first;
}
bool feascheck(int mid,int k){
int temp=0;
int i=0;
while(temp<k&&a[i].first/mid!=0){
temp+=a[i].first/mid;
i++;
}
if(temp<k)return 0;
return 1;

}
int main() {
int n,k;
cin>>n>>k;
vector<int>b(n);
for(int i=0;i<n;i++){
  cin>>b[i];
  a[b[i]].first++;
  a[b[i]].second=b[i];
}
sort(a.begin(),a.end(),comp);
int min1=INT_MAX;
int max1=-1;
int s=1,e=a[0].first;
while(s<=e){
  int mid=(s+e)/2;
if(feascheck(mid,k)){
max1=max(max1,mid);
s=mid+1;
}
else e=mid-1;
}

int count1=0;
for(int i=0;i<a.size();i++){
  for(int j=0;j<a[i].first/max1;j++){
    cout<<a[i].second<<" ";
    count1++;
    if(count1==k)break;
  }
  if(count1==k)break;
}
cout<<endl;

}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z > 0){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		ll rop = (pq.size() * pq.top().first) / z;
		if (rop){
			ll rep = ((pq.top().first) / rop) * pq.size();
			if ((i + 1 < v.size() && (pq.size() * pq.top().first) / z >= v[i + 1].first) && rep >= z || i == v.size() - 1 && rep >= z){
				last = (pq.size() * pq.top().first) / z;
				while (z > 0){
					for (int k = 0; k + last <= pq.top().first; k += last){
						cout << pq.top().second << " ";
						z--;
						if (z <= 0){
							break;
						}
					}
					pq.pop();
				}
				cout << endl;
				return 0;
			}
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
						if (size >= z){
							break;
						}
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if (((i + 1 < v.size() && pq.top().first / 2 >= v[i + 1].first)) && pq.size() * 2 >= z){
			while (z){
				cout << pq.top().second << " ";
				z--;
				if (z <= 0){
					break;
				}
				cout << pq.top().second << " ";
				pq.pop();
				z--;
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
						if (size >= z){
							break;
						}
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if (((i + 1 < v.size() && pq.top().first / 2 > v[i + 1].first)) && pq.size() * 2 >= z){
			while (z){
				cout << pq.top().second << " ";
				z--;
				if (z <= 0){
					break;
				}
				cout << pq.top().second << " ";
				pq.pop();
				z--;
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}