Vicious Keyboard

Tonio has a keyboard with only two letters, "V" and "K".

One day, he has typed out a string s with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times "VK" can appear as a substring (i. e. a letter "K" right after a letter "V") in the resulting string.

Input

The first line will contain a string s consisting only of uppercase English letters "V" and "K" with length not less than 1 and not greater than 100.

Output

Output a single integer, the maximum number of times "VK" can appear as a substring of the given string after changing at most one character.

Examples

Input

VK

Output

1

Input

VV

Output

1

Input

V

Output

0

Input

VKKKKKKKKKVVVVVVVVVK

Output

3

Input

KVKV

Output

1

Note

For the first case, we do not change any letters. "VK" appears once, which is the maximum number of times it could appear.

For the second case, we can change the second character from a "V" to a "K". This will give us the string "VK". This has one occurrence of the string "VK" as a substring.

For the fourth case, we can change the fourth character from a "K" to a "V". This will give us the string "VKKVKKKKKKVVVVVVVVVK". This has three occurrences of the string "VK" as a substring. We can check no other moves can give us strictly more occurrences

题意:
      输入一个字符串,输出其中有多少对VK,可以任意更改其中的一个字符串使VK对的数量最多。

思路:

     先一遍循环求出VK的数量,用无意义的字符代替,再一遍循环找VV或KK,有的话加一

代码:

  

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<map>
#include<set>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
int main(){
    string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<s.length()-1;i++){
		if(s[i]=='V'&&s[i+1]=='K'){
			cnt++;
			s[i]=s[i+1]='0';
		}
	} 
	for(int i=0;i<s.length();i++){
		if((s[i]=='V'&&s[i+1]=='V') || (s[i]=='K'&&s[i+1]=='K')){
			cnt++;
			break;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

OUC_lkc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值