

=> (1)을 보면, 연속된 수가 끊기지 않는다면 출력은 0이다.
(2). (3)를 보면, 연속된 수가 1번 또는 2번 끊겼다면 출력은 0이다.
(4), (5)를 보면, 연속된 수가 3번 이상 끊길 경우, 끊긴 횟수 n를 2로 나누면 된다. (n이 홀수라면 올림)
String str = br.readLine();
char before = str.charAt(0);
int count = 0;
for(int i = 1; i<str.length(); i++){
if(str.charAt(i) != before) {
count++;
before = str.charAt(i);
}
}
if (count == 0 )
System.out.println(0);
else if (count == 1 || count == 2)
System.out.println(1);
else System.out.println(count/2 + count%2);
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
char before = str.charAt(0);
int count = 0;
for(int i = 1; i<str.length(); i++){
if(str.charAt(i) != before) {
count++;
before = str.charAt(i);
}
}
if (count == 0 )
System.out.println(0);
else if (count == 1 || count == 2)
System.out.println(1);
else System.out.println(count/2 + count%2);
}
}