AlgoUniversity
  • Go Back
Discussion
Min Deletions :

Author

Akshay Sharma

Difficulty Level : Medium

Submissions : 438

Asked In : Microsoft

Marks :100

: 4 | : 0

Given a string with only characters X and Y. Find the minimum number of characters to remove from the string such that there is no interleaving of characters X and Y and all the Xs appear before any Y.

Input

The first and online line of input contains a string S ($$$1 le S \le 1e5$$$)

Output

For each test case print, the minimum number of characters to remove

Examples

Input
YXXXYXY
Output
2
Input
YYXYXX
Output
3

Note

For the first test case :

We can obtain XXXYY by:

Delete the first Y—XXXYXY

Delete the last occurrence of X –XXXYY

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.