class Solution {
public:
bool detectCapitalUse(string word) {
int n=word.size();
int k=0;
if(word[0]>='A'&&word[0]<='Z') k=1;
int k2=0,k3=0;
for(int i=1;i<n;i++){
if(word[i]>='A'&&word[i]<='Z') k2=1;
else k3=1;
}
if(k&&k2==0) return true;
if(k&&k3==0) return true;
if(k==0&&k2==0) return true;
return false;
}
};