|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초 (추가 시간 없음)||256 MB||2||2||2||100.000%|
Johnny wants to become a professional road cyclist. He has even found the perfect bike, but he does not have the funds to buy it. He asked his mother for a daily pocket money allowance, to which she agreed under some terms: the initial amount of the pocket money is $0$ and then every day mother will give Johnny the current amount of pocket money and then check Johnny's grades -- if he brings more fives and sixes than the twos and ones, she will raise the pocket money by one, if less -- she will decrease it by 1, and in the remaining case the value does not change. If the value gets negative, mother will stop paying Johnny at all and he will never buy the bike.
Years later, John recalls those events with great affection. He still remembers many details: he collected exactly the bike's cost and the final amount of his pocket money was $0$. One thing he cannot recall is the actual price of the bike. He even found his grade sheets, but they are old and tattered, so sometimes he cannot read what grades he got each day. Can you help John and compute the best upper and lower bounds on the price of the bike? Unfortunately, it is possible that John made some mistakes when reading the grades and it is not possible to write a correct sequence of pocket money amounts consistent with the data that John provided.
The first and only line of the input contains one string of length at most $10^6$, consisting of symbols '
0' and '
_'. The characters represent changes of the pocket money in the following days: '
+' means that on this day Johnny's mother raised his pocket money (by $1$), '
-' means that on this day she decreased it (by $1$), '
0' means that the pocket money amount has not changed, and '
_' means that John is unable to say what happened on this particular day.
You should write in the first and only line of the output two integers, separated by a single space, denoting the minimal and maximal possible price of the bike, respectively.
If the given string cannot be turned into a valid sequence of changes of the pocket money amount, then you should write a single word
NIE instead (Polish for "no").
In Sample 1, the lowest bike price is achieved for the sequence "
+-+-0000+-", the largest for "
In Sample 2, regardless of the grades in the first two days, the amount of the pocket money after the fifth day would be negative.