300959: CF180C. Letter
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Letter
题意翻译
题目描述: 给你一个字符串,我们每一次操作都可以将一个大写字母变成任意小写字母,当然同理也可以将小写字母变成任意大写字母,问最少操作多少次,能够使得字符串变成前边都是大写字母,后边都是小写字母。 输入格式: 输入的唯一行包含一个由大写字母和小写字母组成的非空字符串。字符串的长度不超过10^5个 输出格式: 输出一个数字最少删除次数题目描述
Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase. Patrick believes that a message is fancy if any uppercase letter stands to the left of any lowercase one. In other words, this rule describes the strings where first go zero or more uppercase letters, and then — zero or more lowercase letters. To make the message fancy, Patrick can erase some letter and add the same letter in the same place in the opposite case (that is, he can replace an uppercase letter with the lowercase one and vice versa). Patrick got interested in the following question: what minimum number of actions do we need to make a message fancy? Changing a letter's case in the message counts as one action. Patrick cannot perform any other actions.输入输出格式
输入格式
The only line of the input contains a non-empty string consisting of uppercase and lowercase letters. The string's length does not exceed $ 10^{5} $ .
输出格式
Print a single number — the least number of actions needed to make the message fancy.
输入输出样例
输入样例 #1
PRuvetSTAaYA
输出样例 #1
5
输入样例 #2
OYPROSTIYAOPECHATALSYAPRIVETSTASYA
输出样例 #2
0
输入样例 #3
helloworld
输出样例 #3
0