4813: 图片预览

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:3 通过:2

题目描述

Vasya的电话里有n张照片。1号照片目前在手机上打开。通过在屏幕上滑动手指,可以向左和向右移动到相邻的照片。如果你从第一张照片向左滑动,你就会到达第n张照片。同样,从最后一张照片向右滑动,你会到达第1张照片。
对于每张照片,我们都知道它的方向是什么--水平或垂直。手机是垂直方向的,不能旋转。改变照片的方向需要b秒。
Vasya有T秒的时间看照片。他想尽可能多地观看照片。如果Vasya第一次打开照片,他要花1秒钟来注意照片的所有细节。如果照片的方向不对,他要花b秒时间旋转照片再看。如果Vasya已经打开了照片,他就跳过它(所以他不花任何时间来观察它或改变它的方向)。不允许跳过未看过的照片。
帮助Vasya找到他在T秒内能够观看的最大数量的照片。


Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a seconds to swipe from photo to adjacent.
For each photo it is known which orientation is intended for it − horizontal or vertical. Phone is in the vertical orientation and can't be rotated. It takes b second to change orientation of the photo.
Vasya has T seconds to watch photos. He want to watch as many photos as possible. If Vasya opens the photo for the first time, he spends 1 second to notice all details in it. If photo is in the wrong orientation, he spends b seconds on rotating it before watching it. If Vasya has already opened the photo, he just skips it (so he doesn't spend any time for watching it or for changing its orientation). It is not allowed to skip unseen photos.
Help Vasya find the maximum number of photos he is able to watch during T seconds.
Input
The first line of the input contains 4 integers n,a,b,T (1≤n≤5·105, 1≤a,b≤1000, 1≤T≤109) − the number of photos, time to move from a photo to adjacent, time to change orientation of a photo and time Vasya can spend for watching photo.
Second line of the input contains a string of length n containing symbols 'w' and 'h'.
If the i-th position of a string contains 'w', then the photo i should be seen in the horizontal orientation.
If the i-th position of a string contains 'h', then the photo i should be seen in vertical orientation.
Output
Output the only integer, the maximum number of photos Vasya is able to watch during those T seconds.
Examples
Input
4 2 3 10
wwhw
Output
2
Input
5 2 4 13
hhwhh
Output
4
Input
5 2 4 1000
hhwhh
Output
5
Input
3 1 100 10
whw
Output
0
Note
In the first sample test you can rotate the first photo (3 seconds), watch the first photo (1 seconds), move left (2 second), rotate fourth photo (3 seconds), watch fourth photo (1 second). The whole process takes exactly 10 seconds.
Note that in the last sample test the time is not enough even to watch the first photo, also you can't skip it.

输入格式

输入的第一行包含4个整数n,a,b,T(1≤n≤5·105,1≤a,b≤1000,1≤T≤109)--照片的数量,从一张照片移到另一张照片的时间,改变照片方向的时间和Vasya可以花时间看照片的时间。
输入的第二行包含一个长度为n的字符串,包含符号'w'和'h'。
如果字符串的第i个位置包含'w',那么照片i应该以水平方向被看到。
如果字符串的第i个位置包含'h',那么照片i应该以垂直方向被看到。

输出格式

输出唯一的整数,即Vasya在这T秒内能够观看的最大照片数。

输入样例 复制

5 2 4 13
hhwhh

输出样例 复制

4

数据范围与提示

在第一个样例中,你可以旋转第一张照片(3秒),观看第一张照片(1秒),向左移动(2秒),旋转第四张照片(3秒),观看第四张照片(1秒)。整个过程正好需要10秒。
请注意,在最后一个样例中,时间甚至不足以观看第一张照片,也不能跳过它。