CF180C.Letter

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 10510^{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
    
首页