Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not carry in his hands objects of two different types. In other words, Polycarpus can't carry both postcards and photos simultaneously. Sometimes he goes to the closet and puts the objects there, thus leaving his hands free. Polycarpus must put all the postcards and photos to the closet. He cannot skip objects. What minimum number of times he should visit the closet if he cannot carry more than 5 items?

Input

The only line of the input data contains a non-empty string consisting of letters "С" and "P" whose length does not exceed 100 characters. If the i-th character in the string is the letter "С", that means that the i-th object (the numbering goes from the left to the right) on Polycarpus' wall is a postcard. And if the i-th character is the letter "P", than the i-th object on the wall is a photo.

Output

Print the only number — the minimum number of times Polycarpus has to visit the closet.

Examples

Input

CPCPCPC


Output

7


Input

CCCCCCPPPPPP


Output

4


Input

CCCCCCPPCPPPPPPPPPP


Output

6


Input

CCCCCCCCCC


Output

2

Note

In the first sample Polycarpus needs to take one item to the closet 7 times.

In the second sample Polycarpus can first take 3 postcards to the closet; then 3 more. He can take the 6 photos that are left in the similar way, going to the closet twice.

In the third sample Polycarpus can visit the closet twice, both times carrying 3 postcards. Then he can take there 2 photos at once, then one postcard and finally, he can carry the last 10 photos if he visits the closet twice.

In the fourth sample Polycarpus can visit the closet twice and take there all 10 postcards (5 items during each go).

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
import math
l = list(map(str, input()))
t = 0
while len(l) != 0:
	c = 0
	b = l[0]
	x = 1
	while True:
		if x == len(l):
			t += math.ceil(x / 5)
			l = []
			break
		elif b == l[x]:
			x += 1
		else:
			t += math.ceil(x / 5)
			l = l[x:]
			break
print(t)


s = input()
res = [[s[0], 0]]
for c in s:
	if c == res[-1][0]:
		res[-1][1] += 1
	else:
		res.append([c, 1])
ans = 0
for (a, b) in res:
	ans += (b + 4) // 5
print(ans)


t = input()
x = ''
i = 0
s = 0
for a in t:
	if a == x:
		i += 1
	else:
		s += 1
		i = 0
	if i == 5:
		s += 1
		i = 0
	x = a
print(s)


l = input()
m = 0
n = 0
for i in range(1, len(l)):
	m += 1
	if l[i] != l[i - 1]:
		m = 0
		n += 1
	elif m == 5:
		m = 0
		n += 1
print(n + 1)


s = input()
c = 1
ans = 1
for i in range(1, len(s)):
	if s[i] == s[i - 1]:
		c += 1
		if c > 5:
			c = 1
			ans += 1
	else:
		c = 1
		ans += 1
print(ans)


string = input()
num_times = 0
counter = 0
prev = string[0]
for char in string:
	if char == prev and counter < 5:
		counter += 1
	elif char == prev and counter >= 5:
		counter = 1
		num_times += 1
	elif char != prev:
		counter = 1
		num_times += 1
		prev = char
num_times += 1
print(num_times)


n = list(input())
c = []
if len(n) == 1:
	print(1)
else:
	d = 1
	for i in range(len(n) - 1):
		if n[i] == n[i + 1]:
			if d == 0:
				d += 2
			else:
				d += 1
		else:
			c.append(d)
			d = 1
		if i == len(n) - 2 and n[-1] == n[-2]:
			c.append(d)
	if n[-1] != n[-2]:
		c.append(1)
	a = 0
	for i in c:
		if i % 5 != 0:
			a += i // 5 + 1
		else:
			a += i // 5
	print(a)


x = input()
k = 0
z = 0
c = ''
for i in x:
	if k == 0:
		c = i
	if c == i and k < 5:
		k += 1
	else:
		z += 1
		k = 1
		c = i
if k != 0:
	z += 1
print(z)


daf = list(input())
count = 0
current = 'X'
num_current = 5
for x in daf:
	if num_current >= 5:
		count += 1
		current = x
		num_current = 1
	elif current == x:
		num_current += 1
	else:
		count += 1
		num_current = 1
		current = x
print(count)


s = input()
c = []
ans = 0
for i in s:
	if len(c) == 0:
		c.append(i)
	elif len(c) != 0 and i == 'C' and (c[-1] == 'P'):
		ans = ans + 1
		c = []
		c.append(i)
	elif len(c) != 0 and i == 'P' and (c[-1] == 'C'):
		ans = ans + 1
		c = []
		c.append(i)
	elif len(c) == 5:
		c = []
		c.append(i)
		ans = ans + 1
	else:
		c.append(i)
print(ans + 1)


s = input()
n = len(s)
total = 0
i = 0
while i < len(s):
	ch = s[i]
	totcarry = 0
	while i < len(s) and s[i] == ch and (totcarry < 5):
		totcarry += 1
		i += 1
	total += 1
print(total)


def main():
	s = input()
	photos_count = 0
	cards_count = 0
	n_closet_visites = 0
	for c in s:
		if c == 'P':
			if cards_count > 0:
				n_closet_visites += 1
				cards_count = 0
				photos_count = 1
			else:
				photos_count += 1
				if photos_count == 5:
					n_closet_visites += 1
					photos_count = 0
		elif c == 'C':
			if photos_count > 0:
				n_closet_visites += 1
				photos_count = 0
				cards_count = 1
			else:
				cards_count += 1
				if cards_count == 5:
					n_closet_visites += 1
					cards_count = 0
	if photos_count > 0 or cards_count > 0:
		n_closet_visites += 1
		photos_count = 0
		cards_count = 0
	print(n_closet_visites)
main()


import sys
import math
s = str(input())
(c, p, cona) = (0, 0, 0)
for i in range(len(s)):
	if s[i] == 'C':
		c += 1
		if p != 0:
			cona += p // 5
			if p % 5 != 0:
				cona += 1
			p = 0
	else:
		p += 1
		if c != 0:
			cona += c // 5
			if c % 5 != 0:
				cona += 1
			c = 0
if c != 0 or p != 0:
	cona += c // 5 + p // 5
	if c % 5 != 0 or p % 5 != 0:
		cona += 1
print(cona)


s = list(input())
targ = s[0]
ans = 0
while s:
	i = 1
	while len(s) and s[0] == targ and (i <= 5):
		s.remove(targ)
		i += 1
	ans += 1
	if len(s):
		targ = s[0]
print(ans)


s = input()
l = len(s)
p = s[0]
now = 0
cnt = 0
for i in range(l):
	if now == 0:
		now = 1
		p = s[i]
	elif s[i] == p:
		now += 1
		if now == 5:
			now = 0
			cnt += 1
	else:
		now = 1
		p = s[i]
		cnt += 1
if now > 0:
	cnt += 1
print(cnt)


stena = input()
j = ''
for i in stena:
	if j == '':
		j = i
		vruke = 1
		pohodov = 1
	else:
		if vruke == 0:
			pohodov += 1
		if i == j:
			vruke += 1
		else:
			if vruke != 0:
				pohodov += 1
			vruke = 1
			j = i
	if vruke == 5:
		vruke = 0
print(pohodov)


import math
cc = None
n = 0
o = 0
for c in input() + '.':
	if cc is None:
		cc = c
	if cc != c:
		cc = c
		o += math.ceil(n / 5)
		n = 1
		continue
	n += 1
print(o)


t = input()
(s, count1, count2) = ('', 0, 0)
for elem in t:
	if elem == s:
		count1 += 1
	else:
		count2 += 1
		count1 = 0
	if count1 == 5:
		count2 += 1
		count1 = 0
	s = elem
print(count2)


X = input()
(Count, i) = (0, 0)
while i < len(X):
	(temp, S) = (X[i], 0)
	while i < len(X) and X[i] == temp and (S != 5):
		(i, S) = (i + 1, S + 1)
	Count += 1
print(Count)


st = list(input())
count = 0
for i in range(len(st)):
	if st[i] == '0':
		continue
	else:
		streak = 0
		for j in range(i + 1, i + min(5, len(st) - i)):
			if st[i] == st[j]:
				streak += 1
			else:
				break
		for j in range(streak + 1):
			st[i + j] = '0'
		count += 1
print(count)


data = list(input())
data.append('X')
result = 0
cnt = 1
for i in range(1, len(data)):
	if data[i] == data[i - 1]:
		cnt += 1
	else:
		result += (cnt - 1) // 5 + 1
		cnt = 1
print(result)


s = input()
count = 0
k = 0
for i in range(len(s) - 1):
	k += 1
	if s[i] != s[i + 1]:
		count += 1
		k = 0
	elif k == 5:
		k = 0
		count += 1
print(count + 1)


st = input()
n = len(st)
c1 = 0
p1 = 0
ans = 0
for i in range(n):
	if st[i] == 'C':
		if p1 != 0:
			ans += 1
			p1 = 0
		if c1 >= 5:
			c1 = 0
			ans += 1
		c1 += 1
	else:
		if c1 != 0:
			ans += 1
			c1 = 0
		if p1 >= 5:
			p1 = 0
			ans += 1
		p1 += 1
if p1 != 0 or c1 != 0:
	ans += 1
print(ans)


def solve(s):
	tot = 1
	count = 1
	i = 1
	while i < len(s):
		if s[i] == s[i - 1]:
			if count == 5:
				count = 1
				tot += 1
			else:
				count += 1
		else:
			count = 1
			tot += 1
		i += 1
	return tot

def main():
	s = input()
	print(solve(s))
main()


def next_pos(wall, start):
	distance = 0
	end = len(wall) - 1
	for i in range(start, end):
		if distance == 5:
			return i
		if wall[i] != wall[i + 1]:
			return i + 1
		distance += 1
	if distance == 5:
		return i
	return len(wall)

def main():
	wall = input()
	trips = 0
	current = 0
	while True:
		if current == len(wall):
			break
		current = next_pos(wall, current)
		trips += 1
	print(trips)
main()


n = input()
t = 0
p = ''
m = 0
for c in n:
	if p == '':
		p = c
		m += 1
	elif p != c or m == 5:
		m = 1
		p = c
		t += 1
	elif p == c:
		m += 1
print(t + 1)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x) + '\n')
s = get_string()
prev = s[0]
capacity = 0
visit = 0
for i in range(len(s)):
	if s[i] == prev:
		capacity += 1
		if capacity == 5:
			visit += 1
			capacity = 0
			if i + 1 < len(s):
				prev = s[i + 1]
			else:
				break
	else:
		prev = s[i]
		visit += 1
		capacity = 1
if capacity > 0:
	print(visit + 1)
else:
	print(visit)


from itertools import groupby
from math import ceil
print(sum((ceil(len(tuple(i[1])) / 5) for i in groupby(input()))))


import math
n = input()

def length(s):
	res = []
	counter = 1
	for i in range(1, len(s)):
		if s[i - 1] == s[i]:
			counter += 1
		else:
			res.append(counter)
			counter = 1
	res.append(counter)
	return res
sol = length(n)
for i in range(len(sol)):
	sol[i] = math.ceil(sol[i] / 5)
print(sum(sol))


s = list(input())
s.reverse()
ans = 0
while s:
	ans += 1
	hold = s[-1]
	cnt = 0
	while cnt < 5 and s and (s[-1] == hold):
		cnt += 1
		s.pop()
print(ans)


s = list(input())
n = len(s)
(c, ka) = (0, 0)
for i in range(n - 1):
	if s[i] == s[i + 1]:
		c = c + 1
		if c == 5:
			c = 0
			ka += 1
	else:
		ka += 1
		c = 0
print(ka + 1)


s = input()
n = len(s)
result = 0
counter = 1
for i in range(n - 1):
	if s[i] == s[i + 1]:
		counter += 1
	else:
		if counter % 5 != 0:
			result += counter // 5 + 1
		else:
			result += counter // 5
		counter = 1
result += counter // 5
if counter % 5 != 0:
	result += 1
print(result)


a = input()
s = 1
i = 0
j = 1
p = 0
while i < len(a) - 1:
	if a[i] == a[i + 1]:
		p = p + 1
		if p == 5:
			s = s + 1
			p = 0
		i = i + 1
	elif p > 0 and a[i] != a[i + 1]:
		s = s + 1
		i = i + 1
		p = 0
	else:
		s = s + 1
		i = i + 1
print(s)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
ins = [x for x in input()]
turns = 0
done = 0
while ins:
	curr = ins.pop()
	if len(ins) > 0:
		if curr == ins[-1]:
			done += 1
			if done == 5:
				turns += 1
				done = 0
		else:
			turns += 1
			done = 0
	else:
		turns += 1
print(turns)


a = list(input())
sum = 0
while len(a) != 0:
	s = a[0]
	t = 0
	while len(a) > 0 and a[0] == s:
		a.pop(0)
		t += 1
		if t == 5:
			break
	sum += 1
print(sum)


s = input()
cnt = 1
ans = 1
prev = s[0]
for j in range(1, len(s)):
	if s[j] == prev and cnt < 5:
		cnt += 1
	elif s[j] != prev or cnt == 5:
		ans += 1
		cnt = 1
	prev = s[j]
print(ans)


s = input().strip()
count = 0
i = 0
while i < len(s):
	j = 0
	while j < 5 and i + j < len(s) and (s[i] == s[i + j]):
		j += 1
	i += j
	count += 1
print(count)


line = input()
count = 0
curr = 0
for i in range(0, len(line) - 1):
	if line[i] != line[i + 1] or curr == 4:
		curr = 0
		count += 1
	else:
		curr += 1
if curr != 5:
	count += 1
print(count)


s = input()
cnt = 0
res = 0
for i in range(len(s)):
	if s[i] == s[i - 1]:
		cnt += 1
	else:
		res = res + (cnt + 4) // 5
		cnt = 1
res += (cnt + 4) // 5
print(res)


s = input()
cur = s[0]
cnt = 1
ans = 1
for i in range(1, len(s)):
	x = s[i]
	if cur != x:
		ans = ans + 1
		cnt = 1
		cur = x
	elif cnt < 5:
		cnt = cnt + 1
	else:
		ans = ans + 1
		cnt = 1
		cur = x
print(ans)


import sys
f = sys.stdin
a = f.readline().strip()
prev = a[0]
count = 0
k = 0
for i in a[1:]:
	if i != prev:
		count += 1
		k = 0
	elif i == prev and k < 4:
		k += 1
	elif i == prev and k == 4:
		count += 1
		k = 0
	prev = i
print(count + 1)


from itertools import groupby
print(sum((-(-len(list(g)) // 5) for (_, g) in groupby(input()))))


s = input()
ct = 0
temp = s[0]
for char in s[1:]:
	if temp[-1] == char and len(temp) < 5:
		temp += char
	else:
		ct += 1
		temp = char
print(ct + 1)


(C, P, ans) = (0, 0, 0)
S = input()
for (i, q) in enumerate(S):
	if q == 'C':
		if P != 0:
			ans += 1
			C = 1
			P = 0
		elif C < 5:
			C += 1
		else:
			C = 1
			ans += 1
	elif C != 0:
		ans += 1
		P = 1
		C = 0
	elif P < 5:
		P += 1
	else:
		P = 1
		ans += 1
if C != 0 or P != 0:
	ans += 1
print(ans)


import math
s = input()
ans = 0
i = 0
while i < len(s):
	letter = s[i]
	cnt = 0
	while i < len(s) and s[i] == letter:
		i += 1
		cnt += 1
	ans += math.ceil(cnt / 5)
print(ans)


from itertools import groupby

def splitter(text):
	return ', '.join((''.join(group) for (key, group) in groupby(text))).split(', ')
	print(finalist)
	return finalist

def roundto1(num):
	if num.is_integer() == True:
		return int(num)
	else:
		return int(num) + 1
string = input()
splitstring = splitter(string)
value = 0
tempval = 0
for i in range(len(splitstring)):
	tempval = len(splitstring[i]) / 5
	value += roundto1(tempval)
print(value)


data = list(input())
result = 1
cnt = 1
for i in range(1, len(data)):
	if data[i] != data[i - 1]:
		result += 1
		cnt = 1
	elif cnt == 5:
		result += 1
		cnt = 1
	else:
		cnt += 1
print(result)


s = input()
k = 0
ans = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		k += 1
		if k == 5:
			k = 0
			ans += 1
	else:
		ans += 1
		k = 0
print(ans + 1)


entrada = input()
s = 'a'
count = 0
for letter in entrada:
	if s[len(s) - 1] is letter:
		if len(s) > 4:
			s = letter
			count += 1
		else:
			s += letter
	else:
		s = letter
		count += 1
print(count)


s = list(input())
c = 0
c1 = 0
c2 = ''
for i in s:
	if i == c2:
		c1 += 1
	if c1 >= 5 or i != c2:
		c += 1
		c1 = 0
	c2 = i
print(c)


x = input()
z = []
(p, c) = (0, 0)
for i in x:
	if i == 'P':
		if c != 0:
			z.append(['C', c])
			c = 0
		p += 1
	else:
		if p != 0:
			z.append(['P', p])
			p = 0
		c += 1
if p != 0:
	z.append(['P', p])
elif c != 0:
	z.append(['C', c])
k = 0
for i in z:
	if i[1] % 5 == 0:
		k += i[1] // 5
	else:
		k += i[1] // 5 + 1
print(k)


s = input()
ans = [1]
for i in range(1, len(s)):
	if s[i] != s[i - 1]:
		ans += [1]
	else:
		ans[-1] += 1
ans2 = [ans[i] // 5 + int(ans[i] % 5 != 0) for i in range(len(ans))]
print(sum(ans2))


import math
l = list(input())
k = 1
ans = 0
for i in range(len(l) - 1):
	if l[i] == l[i + 1]:
		k += 1
	else:
		ans += math.ceil(k / 5)
		k = 1
ans += math.ceil(k / 5)
print(ans)


s = input().split()[0]
cur = s[0]
curn = 0
res = 0
i = 0
while i < len(s):
	if curn == 5:
		curn = 0
		res += 1
		i -= 1
	elif s[i] == cur:
		curn += 1
	else:
		if curn != 0:
			res += 1
		curn = 1
		cur = s[i]
	i += 1
res += 1
print(res)


s = input()
t = s[0]
num = 1
res = 1
for i in s[1:]:
	if num >= 5 or not i == t:
		num = 1
		t = i
		res += 1
	else:
		t = i
		num += 1
print(res)


(s, count, out) = (input(), 1, 1)
tem = s[0]
for i in range(1, len(s)):
	if s[i] == tem and count < 5:
		count += 1
	else:
		count = 1
		out += 1
		tem = s[i]
print(out)


def main():
	s = input()
	(l, a) = ([], '*')
	for (i, b) in enumerate(s):
		if a != b:
			a = b
			l.append(i)
	l.append(len(s))
	res = sum(((j - i + 4) // 5 for (i, j) in zip(l, l[1:])))
	print(res)
main()


data = list(input())
cnt = 0
seq = 0
former = 0
for ch in data:
	if former != ch:
		seq = 1
		cnt += 1
		former = ch
	elif seq == 5:
		cnt += 1
		seq = 1
	else:
		seq += 1
print(cnt)


l = input()
a = l[0]
ans = 0
counter = 0
for i in l:
	if i != a or counter == 5:
		a = i
		counter = 0
		ans += 1
	counter += 1
print(ans + 1)


s = input()
carried_item = 1
time = 1
for i in range(1, len(s)):
	if s[i] == s[i - 1] and carried_item < 5:
		carried_item += 1
	else:
		time += 1
		carried_item = 1
print(time)


prev = ''
h = 0
n = 0
for ch in input():
	if ch != prev or h == 5:
		h = 1
		n += 1
	else:
		h += 1
	prev = ch
print(n)


s = input()
a = len(s)
s = s + '0'
p = 0
c = s[0]
i = 0
cnt = 0
while p < a:
	p += 1
	i += 1
	if s[p] != c:
		cnt += 1
		i = 0
		c = s[p]
	if i == 5:
		i = 0
		cnt += 1
		c = s[p]
if i != 0:
	cnt += 1
print(cnt)


import math
s = input()
(cnt, ans) = (1, 1)
for i in range(1, len(s)):
	if s[i] == s[i - 1] and cnt < 5:
		cnt += 1
	else:
		cnt = 1
		ans += 1
print(ans)


a = input()
m = len(a)
k = 1
answ = 0
if m == 1:
	print(1)
	exit()
for i in range(1, m):
	if a[i] == a[i - 1]:
		k += 1
	else:
		answ += k // 5 + int(k % 5 != 0)
		k = 1
	if i == m - 1:
		answ += k // 5 + int(k % 5 != 0)
print(answ)


import sys
from math import sqrt, log, log2, ceil, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left
from bisect import bisect_right
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def solve():
	s = inp()
	s1 = [s[0]]
	c = 0
	for i in range(1, len(s)):
		if len(s1) == 0:
			s1.append(s[i])
		elif s1[-1] != s[i]:
			c += 1
			s1.clear()
			s1.append(s[i])
		else:
			s1.append(s[i])
			if len(s1) == 5:
				c += 1
				s1.clear()
	if s1:
		c += 1
	print(c)
	return
t = 1
for _ in range(t):
	solve()


a = input()
b = [i for i in a.split('P')]
c = [i for i in a.split('C')]
g = 0
for i in range(len(b)):
	if b[i] != '':
		if len(b[i]) <= 5:
			g += 1
		else:
			g += len(b[i]) // 5
			if len(b[i]) % 5 != 0:
				g += 1
for i in range(len(c)):
	if c[i] != '':
		if len(c[i]) <= int(5):
			g += 1
		else:
			g += len(c[i]) // 5
			if len(c[i]) % 5 != 0:
				g += 1
print(g)


t = input()
count = 1
r = 1
flag = 0
for i in range(1, len(t)):
	if t[i] == t[i - 1]:
		r = r + 1
	if r > 5 or t[i] != t[i - 1]:
		r = 1
		count = count + 1
		continue
print(count)


from sys import stdin, stdout
ans = 0
s = stdin.readline().strip()
cnt = 0
while len(s):
	ans += 1
	if s[:5].count(s[0]) == len(s[:5]):
		s = s[5:]
	else:
		for i in range(1, len(s)):
			if s[i] != s[i - 1]:
				s = s[i:]
				break
stdout.write(str(ans))


l = list(input())
co = 0
num = 0
typ = l[0]
for i in range(len(l)):
	if l[i] == typ:
		num += 1
	elif num == 0:
		typ = l[i]
		num = 1
	else:
		co += 1
		typ = l[i]
		num = 1
	if num > 4:
		num = 0
		co += 1
if num > 0:
	co += 1
print(co)


w = list(input())
if w == []:
	print(0)
else:
	times = 1
	count = 0
	t = w[0]
	for c in w:
		if c == t:
			if count < 5:
				count += 1
		else:
			if count != 0:
				times += 1
			t = c
			count = 1
		if count == 5:
			times += 1
			count = 0
	if count == 0:
		print(times - 1)
	else:
		print(times)


s = input()
c = 0
t = 0
old = ''
for i in s:
	if i == old:
		c += 1
	if c >= 5 or i != old:
		t += 1
		c = 0
	old = i
print(t)


a = 0
d = 0
ans = 0
for i in input():
	if i == 'C':
		a += 1
		if d > 0:
			ans += 1
			d = 0
	elif i == 'P':
		d += 1
		if a > 0:
			ans += 1
			a = 0
	if a == 5 or d == 5:
		ans += 1
		a = a % 5
		d = d % 5
if d > 0 or a > 0:
	ans += 1
print(ans)


s = input()
p = 'w'
k = 0
k1 = 1
for x in s:
	if x != p:
		k += 1
		k1 = 1
		p = x
	else:
		k1 += 1
		if k1 == 6:
			k += 1
			k1 = 1
			p = x
print(k)


a = input()
ans = 0
i = 0
while i < len(a):
	j = i + 1
	while j < len(a) and a[j] == a[i] and (j - i < 5):
		j += 1
	ans += 1
	i = j
print(ans)


s = input()
cnt = 0
while s:
	i = 0
	while i < min(5, len(s)):
		if s[i] == s[0]:
			i += 1
		else:
			break
	cnt += 1
	s = s[i:]
print(cnt)


str = input()
count = result = 1
for i in range(int(len(str) - 1)):
	if str[i] == str[i + 1] and count < 5:
		count += 1
	else:
		count = 1
		result += 1
print(result)


s = input()
last = s[0]
res = 0
count = 0
for c in s:
	if c != last or count == 5:
		res += 1
		count = 1
	else:
		count += 1
	last = c
if count > 0:
	res += 1
print(res)


s = input()
rs = 0
i = 0
while i < len(s):
	j = i + 1
	while j < len(s) and s[j] == s[i] and (j - i < 5):
		j += 1
	rs += 1
	i = j
print(rs)


x = input()
counter = 1
dlina = 1
for i in range(1, len(x)):
	if x[i] == x[i - 1]:
		dlina += 1
		if dlina == 6:
			counter += 1
			dlina = 1
	else:
		dlina = 1
		counter += 1
print(counter)


st = input()
con = 1
ans = 1
pre = st[0]
for i in range(1, len(st)):
	if pre == st[i] and con < 5:
		con += 1
	else:
		con = 1
		ans += 1
	pre = st[i]
print(ans)


objects = input()
prev = 'P' if objects[0] == 'C' else 'C'
ans = 0
cnt = 0
for e in objects:
	if e == prev and cnt < 5:
		cnt += 1
	else:
		ans += 1
		cnt = 1
	prev = e
print(ans)


z = input()
z += 'O'
s = 0
p = 0
for i in range(len(z) - 1):
	if s <= 5:
		if z[i] == z[i + 1]:
			s += 1.5
		else:
			p += 1
			s = 0
	else:
		p += 1
		s = 0
print(p)


s = input()
count = 0
ans = 1
for i in range(1, len(s)):
	if count == 4 or (count <= 4 and s[i] != s[i - 1]):
		count = 0
		ans += 1
	elif s[i] == s[i - 1]:
		count += 1
	if s[i] != s[i - 1] and count != 0:
		ans += 1
		count = 0
print(ans)


s = input()
print(sum([(len(x) + 4) // 5 for x in s.split('P') + s.split('C')]))


s = input()
lst = []
prev = s[0]
count = 1
for c in range(1, len(s)):
	if prev == s[c]:
		count += 1
	else:
		lst.append(count)
		count = 1
	prev = s[c]
lst.append(count)
count = 0
for c in lst:
	if c % 5 != 0:
		count += c // 5 + 1
	else:
		count += c // 5
print(count)


string = input() + '.'
idx = 0
cnt = 1
ans = 0
for i in range(1, len(string)):
	if string[i] == string[i - 1]:
		cnt += 1
	else:
		ans += cnt // 5
		if cnt % 5 != 0:
			ans += 1
		cnt = 1
print(ans)


def post_cards():
	string = input()
	dic = {'C': 0, 'P': 0}
	if len(string) == 1:
		return 1
	aux = string[0]
	output = 0
	for i in range(len(string)):
		if string[i] != aux:
			output += 1
			dic[aux] = 0
			aux = string[i]
			dic[aux] = 1
		else:
			dic[string[i]] += 1
			if dic[string[i]] == 5:
				dic[string[i]] = 0
				aux = '?'
	output += 1
	return output
A = post_cards()
print(A)


import sys
import math
import bisect

def main():
	s = input()
	n = len(s)
	ans = []
	A = []
	for i in range(n):
		A.append(s[i])
		if i == n - 1 or s[i + 1] != s[i] or len(A) == 5:
			ans.append(A.copy())
			A.clear()
	print(len(ans))
main()


s = input()
(count, a, t) = (0, 0, s[0])
for i in s:
	if i != t or a == 5:
		(count, a) = (count + 1, 0)
	(a, t) = (a + 1, i)
print(count + 1)


l = input()
a = l[0]
s = j = 0
for i in l:
	if i != a or j == 5:
		a = i
		j = 0
		s += 1
	j += 1
print(s + 1)


__author__ = 'Esfandiar'
s = input()
t = 0
res = 1
b = s[0]
for i in s:
	if i == 'C':
		if t < 5 and i == b:
			t += 1
		else:
			res += 1
			t = 1
			b = 'C'
	elif t < 5 and i == b:
		t += 1
	else:
		res += 1
		t = 1
		b = 'P'
print(res)


s = input()
c = 0
d = 0
if len(s) > 1:
	for i in range(len(s) - 1):
		if s[i] != s[i + 1]:
			c = c + 1
			d = 0
		else:
			d = d + 1
			if d == 5:
				d = 0
				c = c + 1
	if s[-1] == s[-2] and d != 5:
		c = c + 1
	elif s[-1] != s[-2]:
		c = c + 1
	print(c)
else:
	print(1)


(t, p, s) = (input(), {}, 1)
for i in range(1, len(t)):
	if t[i] == t[i - 1]:
		s += 1
	else:
		p[s] = p.get(s, 0) + 1
		s = 1
p[s] = p.get(s, 0) + 1
s = 0
for i in p:
	s += p[i] * ((i - 1) // 5 + 1)
print(s)


s = input()
a = 0
t = 1
for i in range(1, len(s)):
	if s[i - 1] == s[i]:
		t = t + 1
	else:
		a = a + (t + 4) // 5
		t = 1
a = a + (t + 4) // 5
print(a)


from itertools import groupby as g
from math import ceil as c
print(sum((c(len(tuple(i[1])) / 5) for i in g(input()))))


list_str = input()
c = list_str[0]
cnt = 0
list_res = []
for i in list_str:
	if i == c and cnt < 5:
		cnt += 1
	else:
		c = i
		cnt = 1
		list_res.append(cnt)
if cnt > 0:
	list_res.append(cnt)
print(len(list_res))


import os, sys
from io import BytesIO, IOBase
from collections import deque, Counter, defaultdict as dft
from heapq import heappop, heappush
from math import log, sqrt, factorial, cos, tan, sin, radians, log2, ceil, floor
from bisect import bisect, bisect_left, bisect_right
from decimal import *
import sys, threading
from itertools import permutations, combinations
from copy import deepcopy
input = sys.stdin.readline
ii = lambda : int(input())
si = lambda : input().rstrip()
mp = lambda : map(int, input().split())
ms = lambda : map(str, input().strip().split(' '))
ml = lambda : list(mp())
mf = lambda : map(float, input().split())
alphs = 'abcdefghijklmnopqrstuvwxyz'

def solve():
	s = input()
	res = 0
	curr = 0
	pre = '*'
	for c in s:
		if c != pre:
			if curr:
				res += 1
			curr = 1
		else:
			curr += 1
			res += curr // 5
			curr %= 5
		pre = c
	if curr:
		res += 1
	print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
tc = 1
for i in range(tc):
	solve()


a = input()
x = a[0]
r = j = 0
for c in a:
	if c != x or j == 5:
		x = c
		j = 0
		r += 1
	j += 1
print(r + 1)


a = input()
cnt = 0
ans = 0
t = a[0]
for i in range(len(a)):
	if a[i] == t:
		cnt += 1
	else:
		ans += 1
		cnt = 1
	if cnt == 5:
		if i + 1 != len(a):
			if a[i + 1] != t:
				i += 1
			ans += 1
			cnt = 0
	t = a[i]
print(ans + 1 if cnt != 0 else ans)


s = input()
n = len(s)
sub = s[0]
c = 1
for i in range(n - 1):
	if s[i + 1] != sub[-1] or len(sub) >= 5:
		sub = s[i + 1]
		c += 1
	elif s[i + 1] == sub[-1] and len(sub) < 6:
		sub += s[i + 1]
print(c)


s = list(input())
i = 1
j = 0
if len(s) == 1:
	print(1)
k = []
while len(s) > 1:
	k = []
	v = 0
	while len(k) < 5 and len(s) > 1:
		if s[0] == s[1]:
			k.append(s[0])
			s.pop(0)
		else:
			k.append(s[0])
			s.pop(0)
			break
	if len(s) == 1 and len(k) == 5:
		j += 2
		break
	elif len(s) == 1 and k[len(k) - 1] != s[0]:
		j += 2
		break
	j += 1
if j > 0:
	print(j)


a = input()
i = 0
sumi = 0
while i < len(a):
	k = a[i]
	j = i
	while a[j] == k:
		j = j + 1
		if j == len(a):
			break
	j = j - 1
	l = j - i + 1
	if l % 5 == 0:
		sumi = sumi + l // 5
	else:
		sumi = sumi + l // 5 + 1
	i = j + 1
print(sumi)


a = input()
import math
p = 0
s = ''
t = 0
for k in range(len(a)):
	if k == 0:
		if a[k] == 'C':
			s = 'C'
			t += 1
		else:
			s = 'P'
			t += 1
	elif a[k] == s:
		t += 1
	else:
		p += math.ceil(t / 5)
		t = 1
		if s == 'C':
			s = 'P'
		else:
			s = 'C'
p += math.ceil(t / 5)
print(p)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def revn(n):
	m = 0
	while n > 0:
		m = m * 10 + n % 10
		n = n // 10
	return m
s = input()
i = ans = 0
while i < len(s):
	t = 5
	while len(set(s[i:i + t])) > 1:
		t -= 1
	i += t
	ans += 1
print(ans)


a = list(input())
r = a[0]
count = 1
i = 0
for j in a:
	if i == 5 or j != r:
		count += 1
		i = 1
		r = j
	else:
		i += 1
print(count)


l = list(input())
t = l[0]
ans = 1
ii = 0
for x in l:
	if ii == 5 or x != t:
		ans += 1
		ii = 1
		t = x
	else:
		ii += 1
print(ans)


from math import ceil as c
(l, s, i) = (0, 0, input())
for x in range(1, len(i)):
	if i[x] != i[x - 1]:
		s += c((x - l) / 5)
		l = x
print(s + c((len(i) - l) / 5))


s = input().strip()
count = 1
previous = s[0]
loads = 1
for ch in s[1:]:
	if ch != previous or count == 5:
		loads += 1
		count = 1
		previous = ch
	else:
		count += 1
print(loads)


s = input()
p = 1
m = 1
for i in range(0, len(s) - 1):
	if s[i] == s[i + 1]:
		if p == 5:
			p = 0
			m += 1
		p += 1
	else:
		p = 1
		m += 1
print(m)


import sys
import math
n = sys.stdin.readline()
l = len(n)
c = n[0]
count = 0
res = 0
for i in n[:l - 1]:
	if c == i:
		count += 1
	else:
		c = i
		res += int(count / 5)
		res += count % 5 != 0 if 1 else 0
		count = 1
res += int(count / 5)
res += count % 5 != 0 if 1 else 0
print(res)


str = input()
n = len(str)
count = 0
hand = []
for i in range(0, n):
	if hand.__len__() == 0:
		hand.append(str[i])
	elif str[i] == hand[-1] and hand.__len__() < 5:
		hand.append(str[i])
	else:
		count = count + 1
		hand = [str[i]]
print(count + (hand.__len__() != 0))


from math import ceil as u
s = input()
c = s.split('P')
p = s.split('C')
k = 0
for i in c:
	if i != '':
		k += u(len(i) / 5)
for i in p:
	if i != '':
		k += u(len(i) / 5)
print(k)


read = input()
counter = 0
maxI = 0
for i in range(len(read) - 1):
	if maxI == 0:
		counter += 1
	if maxI == 4 or read[i] != read[i + 1]:
		maxI = 0
	else:
		maxI += 1
i = len(read) - 1
if read[i] != read[i - 1]:
	counter += 1
elif maxI == 0:
	counter += 1
print(counter)


def count_times(row):
	res = int(row != '')
	hand = 0
	n = len(row)
	for i in range(1, n):
		hand += 1
		if hand == 5 or row[i] != row[i - 1]:
			hand = 0
			res += 1
	return res
row = input()
print(count_times(row))


n = input()
y = len(n)
rook = 0
count = 0
u = 'K'
for i in range(y):
	if rook > 5:
		rook = 1
		count += 1
	elif u != n[i]:
		count += 1
		rook = 1
	rook += 1
	u = n[i]
print(count)


import math
s = input()
c = 0
n = len(s)
i = 0
p = s[0]
ans = 0
while i < n:
	if s[i] == p:
		c += 1
	else:
		ans += math.ceil(c / 5)
		p = s[i]
		c = 1
	i += 1
ans += math.ceil(c / 5)
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
s = input()
ans = 0
countc = 0
countp = 0
for i in range(0, len(s)):
	if s[i] == 'C':
		if countp > 0:
			ans += 1
			countp = 0
		countc += 1
	if s[i] == 'P':
		if countc > 0:
			ans += 1
			countc = 0
		countp += 1
	if countc == 5:
		ans += 1
		countc = 0
	if countp == 5:
		ans += 1
		countp = 0
if countp > 0 or countc > 0:
	ans += 1
print(ans)


s = str(input())
i = 0
count = 0
while len(s) > 0:
	if s[0] == 'C':
		temp = s.lstrip('C')
		if len(s) - len(temp) > 5:
			s = s[5:]
		else:
			s = temp
		count = count + 1
	else:
		temp = s.lstrip('P')
		if len(s) - len(temp) > 5:
			s = s[5:]
		else:
			s = temp
		count = count + 1
print(count)


from itertools import groupby
grouped = groupby(list(input()))
result = 0
for (_, elements) in grouped:
	tmp = list(elements)
	amount = len(tmp)
	result += (amount + 4) // 5
print(result)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
print(sum([math.ceil(len(list(j)) / 5) for (i, j) in groupby(input())]))


s = input()
(i, ans, last) = (1, 0, s[0])
while True:
	if i == len(s):
		if len(last) > 0:
			ans += 1
		break
	if last[-1] != s[i]:
		ans += 1
		last = s[i]
		i += 1
	elif len(last) == 4:
		ans += 1
		i += 1
		if i == len(s):
			break
		last = s[i]
		i += 1
	else:
		last += s[i]
		i += 1
print(ans)


s = str(input())
num = 1
count = 0
t = s[0]
l = len(s)
for i in range(1, l):
	if t == s[i]:
		count += 1
		if count == 5:
			num += 1
			count = 0
	else:
		t = s[i]
		num += 1
		count = 0
print(num)