시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 27 9 9 47.368%

문제

희원이는 국기 인식 시스템을 만들었다. 이 알고리즘은 국기를 6*9크기의 행렬로 필터링 시킨 뒤, 인식한다. 행렬에는 색을 나타내는 알파벳 대문자가 있다.

이 시스템은 아직 개발 초기 단계이기 때문에, 아래와 같이 간단한 형태만 인식할 수 있다.

CCCCCCCCC     CCCCCCCCC     ZZZBBBCCC     ZZZAAAZZZ
CCCCCCCCC     CCCCCCCCC     ZZZBBBCCC     ZZZAAAZZZ
BBBBBBBBB     BBBBBBBBB     ZZZBBBCCC     ZZZAAAZZZ
BBBBBBBBB     BBBBBBBBB     ZZZBBBCCC     ZZZAAAZZZ
PPPPPPPPP     CCCCCCCCC     ZZZBBBCCC     ZZZAAAZZZ
PPPPPPPPP     CCCCCCCCC     ZZZBBBCCC     ZZZAAAZZZ

즉, 위와 같이 삼등분 된 국기만 인식할 수 있다. 가운데 줄의 색상은 다른 두 줄과는 달라야 한다.

인식한 국기가 주어졌을 때, 간단한 형태가 되기 위해 바꿔야 하는 문자의 최소 개수를 구하는 프로그램을 작성하시오.

입력

총 6개줄에 걸쳐 9개 알파벳 대문자가 주어진다.

출력

첫째 줄에 간단한 형태가 되기 위해 바꿔야 하는 문자의 최소 개수를 출력한다.

예제 입력 1

CCCCCCCCC
CCCCCCCCC
CBBBBBBBC
PBBBBBBBP
PPPPPPPPP
PPPPPPPPP

예제 출력 1

4
W3sicHJvYmxlbV9pZCI6IjMxMDAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFkNmRcdWFlMzAgXHVjNzc4XHVjMmRkIiwiZGVzY3JpcHRpb24iOiI8cD5cdWQ3NmNcdWM2ZDBcdWM3NzRcdWIyOTQgXHVhZDZkXHVhZTMwIFx1Yzc3OFx1YzJkZCBcdWMyZGNcdWMyYTRcdWQxNWNcdWM3NDQgXHViOWNjXHViNGU0XHVjNWM4XHViMmU0LiBcdWM3NzQgXHVj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