import java.util.Scanner;

public class SoalA {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String kata = input.next();

		int limit = 0;
		int counter=1;

		for(int i = 0; i < kata.length() - 1; i++) {
			if(kata.charAt(i) == kata.charAt(i+1)) {
				limit += 1;
				if(limit == 5) {
					counter++;
					limit = 0;
				}
			}
			else {
				counter++;
				limit = 0;
			}
		}
		System.out.println(counter);
	}
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.util.*;
/**
 *
 * @author Rohan
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        solve();
    }

    public static void solve() throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);

        String S=br.readLine(); int res=0,count=0;
        for(int i=0;i<S.length();++i){
            ++res; count=1;
            while(count<5 && i+1<S.length() && S.charAt(i)==S.charAt(i+1)){++count; ++i;}
        }
        out.println(res); out.flush(); out.close();
    }
}

import java.util.Scanner;

public class Photos {

    /**
     * @param args
     */
    public static void main(String[] args) {
        postcards();
    }

    public static void postcards() {
        Scanner scanner = new Scanner(System.in);
        String input;
        input = scanner.nextLine();

        int visits = 0;
        int cur = 0;
        int pc = 0;

        for (int i = 0; i < input.length(); i++) {
            if (cur >= 5) {
                visits++;
                cur = 1;
                if (input.charAt(i) == 'P')
                    pc = 1;
                else
                    pc = 2;
            } else if (pc == 1 && input.charAt(i) == 'P')
                cur++;
            else if (pc == 2 && input.charAt(i) == 'C')
                cur++;
            else if (pc == 1 && input.charAt(i) == 'C') {
                visits++;
                cur = 1;
                pc = 2;
            } else if (pc == 2 && input.charAt(i) == 'P') {
                visits++;
                cur = 1;
                pc = 1;
            } else {
                cur++;
                pc = input.charAt(i) == 'P' ? 1 : 2;
            }
        }
        visits++;
        System.out.println(visits);
    }
}

import java.io.PrintWriter;
import java.util.Scanner;

public class Main implements Runnable {

	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	String input;
	int output;
	int counter=1;
	Character c;

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	private void read() {
		input = in.nextLine();
	}

	private void solve() {

		if(input.length()==1) {
			output=1;
			return;
		}

		for (int i = 0; i < input.length()-1; i++) {
//			out.print(input.charAt(i));
			c=input.charAt(i);
			if (c.equals(input.charAt(i + 1))) {
				counter++;
				if (counter == 6) {
					counter = 1;
					output++;

				}
			}

			else if(!c.equals(input.charAt(i + 1))) {
				counter=1;
				output++;
			}

		}
		if(counter!=0)
			output++;

	}

	private void write() {
		out.println(output);
	}

	@Override
	public void run() {
		read();
		solve();
		write();
		in.close();
		out.flush();
		out.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Runnable {
    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) {
        new Thread(new Main()).start();
        // Main m = new Main ();
        // m.run();
    }

    public void run() {
        try {
//            in = new BufferedReader(new FileReader("input.txt"));
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            out = new PrintWriter(new FileWriter("output.txt"));
            solve();
        } catch (Exception e) {
            e.printStackTrace();
//            out.print();
            System.exit(9000);
        } finally {
            out.flush();
            out.close();
        }
    }

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    void solve() throws NumberFormatException, IOException {
        String s = in.readLine();
        int count = 0;
        int cur = 0;
        char e = ' ';// = s.charAt(0);
        for (int i = 0; i < s.length(); ++i) {
            if (cur == 5) {
                ++count;
                cur = 0;
            } else if (e != s.charAt(i) && e != ' ') {
                ++count;
                cur = 0;
                e = ' ';
            }
            if (e == s.charAt(i)) {
                ++cur;
            }
            if (cur == 0) {
                e = s.charAt(i);
                cur = 1;
                continue;
            }
        }
        out.print(count + 1);
    }

    public String convert(String num) {
        long sum = 0;
        for (int i = 0; i < num.length(); ++i) {
            sum += (num.charAt(i) - '0');
        }
        return String.valueOf(sum);
    }

}

import java.util.Scanner;

public class PostcardsAndphotos {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String s = scan.next();
			int counter = 0;
			int len = 0;
			char current = ' ';
			int i = 0;
			for (i = 0; i < s.length() - 1; i++) {
				current = s.charAt(i);
				len = 0;
				while (i < s.length() - 1 && current == s.charAt(i + 1)
						&& len < 4) {
					i++;
					len++;
				}
				counter++;
			}
			if (s.charAt(s.length() - 1) != current || i != s.length())
				counter++;
			System.out.println(counter);
		}
	}
}

import java.util.*;
import java.io.*;

public class A{ //��� ������ ������ ���� Main
  public static void main(String[] argv) throws IOException{
 Scanner in = new Scanner(System.in); int k=0,ans=0;
 String St = in.next();
 for (int i=0;i<St.length();i++) {
	 k++;
	 if (k==5 || (i<St.length()-1 && St.charAt(i)!=St.charAt(i+1)) || i==St.length()-1) {ans++;k=0;} ;
 }

	 System.out.println(ans);

  }

}

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

    private void solve() throws IOException {
        String a = nextToken();
        char lastknown = ' ';
        int count = 1, result = 0;
        for (int x = 0; x < a.length(); x++) {
            if (x == 0 ) {
                lastknown = a.charAt(x);
                continue;
            }

            if (a.charAt(x) == lastknown) {
                count++;
            } else {
                result += Math.ceil((double)((double)count)/(double)5);
                count = 1;
            }
//            System.out.println(x + " "+ count + " " + result);
            lastknown = a.charAt(x);
        }
        if (count > 0) {
            result += Math.ceil((double)((double)count)/(double)5);
        }
        out.println(result);
    }

    public static void main(String[] args) {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            new Main().solve();
            out.close();
        } catch (Throwable e) {
            System.out.println(e);
            System.exit(239);
        }
    }
    static BufferedReader br;
    static StringTokenizer st;
    static PrintWriter out;

    static String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    static int[] nextIntArray(int n) throws IOException {
        int[] temp = new int[n];
        for (int x = 0; x < n; x++) {
            temp[x] = nextInt();
        }
        return temp;
    }

    static long[] nextLongArray(int n) throws IOException {
        long[] temp = new long[n];
        for (int x = 0; x < n; x++) {
            temp[x] = nextLong();
        }
        return temp;
    }

    static String[] nextArray(int n) throws IOException {
        String[] temp = new String[n];
        for (int x = 0; x < n; x++) {
            temp[x] = nextToken();
        }
        return temp;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class A {

    private void solve() throws IOException {
        String s = nextToken();
        Stack<Character> st = new Stack<Character>();
        st.add(s.charAt(0));
        int c = 1;
        int res = 0;
        for (int i = 1; i < s.length(); i++) {
            if (st.isEmpty()) {
                st.add(s.charAt(i));
                continue;
            }
            if (st.peek().equals(s.charAt(i)) && c < 5) {
                c++;
                st.add(s.charAt(i));
            }
            else if (c == 5) {
                st.clear();
                st.add(s.charAt(i));
                res++;
                c = 1;
            }
            else if (!st.peek().equals(s)){
                res++;
                st.pop();
                st.push(s.charAt(i));
                c = 1;
            }
        }
        if (!st.isEmpty()) res++;
        System.out.println(res);
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CopyOfcontest {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub

		InputStreamReader converter = new InputStreamReader(System.in);
		BufferedReader in = new BufferedReader(converter);
		String curline = in.readLine();
		char[] arr = curline.toCharArray();
		int total = 0;
		char cur = 'C';
		int count = 0;
		for(int i=0; i<arr.length; i++) {
			if(count == 0  ) {
				cur = arr[i];
				count ++;
				continue;
			}
			if(cur == arr[i]) {
				count ++;
				if(count==5) {
					count =0;
					total++;
				}
			}
			else {
				cur = arr[i];
				count = 1;
				total++;
			}
		}
		if(count != 0)
		   total++;

		System.out.println(total);

	}
}

import java.util.Scanner;

public class A_137 {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		char[] input = sc.next().toCharArray();

		int time = 0;
		for(int i = 0; i < input.length; i++){
			char cur = input[i];

			int next = i + 1;
			while(next - i < 5){
				if(next >= input.length){
					next--;
					break;
				}else if(input[next] != cur){
					next--;
					break;
				}

				next++;
			}

			if(next - i >= 5){
				next = i + 4;
			}

			//System.out.println(i + " " + next);

			time++;
			i = next;
		}

		System.out.println(time);

		sc.close();
	}

}

import java.io.PrintWriter;
import java.util.Scanner;

public class Main implements Runnable {

	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	String input;
	int output=0;

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	private void read() {
		input = in.nextLine();
	}

	private void solve() {
		int num=1;
		for(int i=0;i<input.length()-1;i++)
		{
			if(num==5)
			{
				output++;
				num=1;
				continue;
			}
			if(input.charAt(i)==input.charAt(i+1))
			{
				num++;
				continue;
			}

			else
			{
				output++;
				num=1;
			}
		}
	}

	private void write() {
		out.println(output+1);
	}

	@Override
	public void run() {
		read();
		solve();
		write();
		in.close();
		out.flush();
		out.close();
	}
}

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Main {

    public static void main(String args[]) throws Exception {
        InputReader sc = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        char arr[] = sc.next().toCharArray();

        int len = arr.length;
        char prev = arr[0];
        int count = 1;
        int internalCount = 1;
        for(int i=1;i<arr.length;i++)
        {
            if(arr[i]==prev)
            {
                if(internalCount<5)
                {
                    internalCount++;
                }
                else
                {
                    internalCount = 1;
                    count++;
                }
            }
            else
            {
                internalCount = 1;
                count++;
                prev = arr[i];
            }
        }
        pw.println(count);

        pw.close();
    }

    static class Node implements Comparable<Node> {
        int v;
        int w;

        Node(int v, int w) {
            this.v = v;
            this.w = w;
        }

        public int compareTo(Node node) {
            if (w == node.w)
                return Integer.compare(v, node.v);

            return (-1) * Integer.compare(w, node.w);
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader reader = new FastReader();
        String s = reader.next();

        int result = 0;
        char curent = 0;
        int len = 0;
        for (char c : s.toCharArray()) {
            if (curent == 0) {
                curent = c;
                len++;
            } else if (curent == c && len < 4) {
                len++;
            } else if (curent == c && len == 4) {
                curent = 0;
                len = 0;
                result++;
            } else {
                curent = c;
                result++;
                len = 1;
            }
        }

        if (curent != 0){
            result++;
        }

        System.out.println(result);
    }

}

import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    //=========================================================================
    public static final String INPUT = "";
    public static final String OUTPUT = "";
    //=========================================================================
    BufferedReader br;
    BufferedWriter bw;
    Scanner in;
    PrintWriter out;
    StreamTokenizer st;
    int nextInt() throws IOException { st.nextToken(); return (int)(st.nval); }
    long nextLong() throws IOException { st.nextToken(); return (long)(st.nval); }
    double nextDouble() throws IOException { st.nextToken(); return st.nval; }
    String nextLine() throws IOException { return br.readLine(); }
    //=========================================================================
    public Main() throws IOException {
        br = new BufferedReader(INPUT.isEmpty() ? new InputStreamReader(System.in) : new FileReader(INPUT));
        bw = new BufferedWriter(OUTPUT.isEmpty() ? new OutputStreamWriter(System.out) : new FileWriter(OUTPUT));
        in = new Scanner(br);
        out = new PrintWriter(bw);
        st = new StreamTokenizer(br);
    }
    public static void main(String[] args) throws IOException {
        new Main().run();
    }
    //=========================================================================

    void run() throws IOException {
        char[] str = in.next().toCharArray();
        int count = 5;
        int ans = 0;
        char cur = ' ';
        for (int i = 0; i <= str.length; ++i) {
            if (i == str.length || count == 5 || cur != str[i]) {
                ++ans;
                if (i != str.length) {
                    count = 1;
                    cur = str[i];
                }
            }
            else {
                ++count;
            }
        }
        out.println(ans - 1);
        out.flush();
    }
}

import java.util.*;

public class Postcards
{
    public static void main(String[] args)
    {
        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter string");
        String st = sc.next();

        int answer = 0;
        int i = 0;
        int conseq = 0;

        while (i < st.length())
        {
            String ch = st.substring(i, i+1);
            while (i < st.length() && conseq < 5 && st.substring(i, i+1).equals(ch))
            {
                i++;
                conseq++;
            }

            if (i < st.length())
            {
                answer++;
                conseq = 0;
            }
        }
        System.out.println(answer+1);
    }
}

import java.util.Scanner;

public class PostCards
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        char arr[];
        int i = 0;
        String input = s.next();
        arr = input.toCharArray();
        int curr = 0;
        int sum = 0;
        i = input.length();
        for(int n=0;n<i-1;n++)
        {
            if(arr[n] != arr[n+1])
            {
                curr = 0;
                sum++;
            }
            else if(arr[n] == arr[n+1] && curr < 4)
            {
                curr++;
            }
            else
            {
                sum++;
                curr = 0;
            }
        }
        System.out.println(sum+1);
    }
}

import java.util.Scanner;
public class Main4{
	public static void main (String [] args){
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		int times = 0 , count = 1;
		for (int i = 1 ; i < s.length() ; i++){
			if (s.charAt(i-1) != s.charAt(i)){
				times++;
				count = 1;
				if (i == s.length()-1)
					times++;
			}
			else{
				count++;
				if (count == 5){
					times++;
					count = 1;
					i++;
				}
				if (i == s.length()-1)
					times++;
			}
		}
		System.out.println((times == 0)? 1 : times);
	}
}

import java.io.*;
import java.util.*;

public class PostcardsAndPhotos {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        String str = f.readLine();
        int count = 0;
        int length = 1;
        for (int i = 1; i < str.length(); i++)
            if (str.charAt(i) == str.charAt(i-1))
                length++;
            else
            {
                count += (length+4)/5;
                length = 1;
            }
        count += (length+4)/5;
        System.out.println(count);
    }
}

import java.util.Scanner;

public class A_Postcards_and_photos {
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s=sc.next()+" ";
    int y=1;
    int k=0;
    for (int i = 1; i <s.length(); i++) {
        if(y==5 || s.charAt(i)!=s.charAt(i-1)){
            y=1;
            k++;
        }
        else
        y++;

    }
    System.out.println(k);
}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws NumberFormatException, IOException {

        InputReader in = new InputReader(System.in);

        String x = in.next();
        int c = 0, k = 0;
        char last = x.charAt(0);
        for(int i = 0; i < x.length(); i++)
            if(k < 5 && x.charAt(i) == last)
                k++;
            else
            {
                c++;
                k = 0;
                last = x.charAt(i--);
            }
        if(k != 0)
            c++;
        System.out.println(c);

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready();}

    }

}

import java.util.*;
import java.io.*;

public class c137 {
	static int f(String s, int n, char c, int ans) {
		if (s.isEmpty()) {
			if (n > 0) return ans + 1;
			else return ans;
		}
		if (n == 5) return f(s, 0, s.charAt(0), ans + 1);
		else {
			if (s.charAt(0) == c)
				return f(s.substring(1), n + 1, s.charAt(0), ans);
			else
				return f(s.substring(1), 1, s.charAt(0), ans + 1);
		}
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int ans = 0;
		ans = f(s, 0, s.charAt(0), ans);
		System.out.println(ans);
	}
}

import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.util.Arrays.fill;

import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import java.text.*;

public class Main {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	final static double EPS = 1e-9;
	final static int MOD = 1000000007;

	static void solve() throws Exception {
		String s = next();
		int res = 0;
		int cnt = 1;
		for (int i = 0; i < s.length(); i++) {
			if (i+1 < s.length() && s.charAt(i+1) == s.charAt(i)) {
				cnt++;
			} else {
				res += cnt / 5;
				if (cnt % 5 != 0) {
					res++;
				}
				cnt = 1;
			}
		}
		out.println(res);
	}

	static long sqr(long x) {
		return x*x;
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static BigInteger nextBigInteger() throws IOException {
		return new BigInteger(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String args[]) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

import java.util.*;
import java.io.*;

public class cf137a {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String x = in.next();

        int ans = 0;
        int cnt = 1;
        char inHand = x.charAt(0);
        for (int i = 1; i < x.length(); i++) {

            if (cnt == 5) {
                cnt = 0;
                ans++;
                inHand = x.charAt(i);
            }

            if (x.charAt(i) == inHand) {
                cnt++;
            } else {
                ans++;
                cnt = 1;
                inHand = x.charAt(i);
            }

        }
        if (cnt > 0) {
            ans++;
        }
        System.out.println(ans);

    }
}

import java.io.*;
import java.util.*;
public class C {
    public static void main(String[] args) throws Exception {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st  = new StringTokenizer(bf.readLine());
	PrintWriter out = new PrintWriter(System.out);
	String s = st.nextToken();
	int num = 1;
	int total = 0;
	char c = s.charAt(0);
	for (int i = 1; i < s.length(); i++)
	{
	    char ch = s.charAt(i);
	    if(ch - c == 0){
		num++;
		if(num == 5){
		    total++;
		    num = 0;
		}
	    }
	    else{
		total+= Math.ceil((double)num/5) ;
		num = 1;
	    }
           c = ch;
	}
	total += Math.ceil((double)num/5) ;
	out.println(total);
	out.flush();
	out.close();
    }
    static class Scanner
    {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
	    while (st == null || !st.hasMoreTokens())
		st = new StringTokenizer(br.readLine());
	    return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
	    String x = next();
	    StringBuilder sb = new StringBuilder("0");
	    double res = 0, f = 1;
	    boolean dec = false, neg = false;
	    int start = 0;
	    if(x.charAt(0) == '-')
	    {
		neg = true;
		start++;
	    }
	    for(int i = start; i < x.length(); i++)
		if(x.charAt(i) == '.')
		{
		    res = Long.parseLong(sb.toString());
		    sb = new StringBuilder("0");
		    dec = true;
		}
		else
		{
		    sb.append(x.charAt(i));
		    if(dec)
			f *= 10;
		}
	    res += Long.parseLong(sb.toString()) / f;
	    return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}
    }

}

/*
 Author: Togrul Gasimov
 Mail: ttogrul30@gmail.com
 */

import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;
import java.util.Scanner;
import java.util.Vector;
import java.util.Arrays;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.List;
import java.util.Stack;

public class Main {

// Function begin

//Function end
static Scanner scan = new Scanner(System.in);
//variables begin
//static double PI=3.1415926535897932384626433832795,E=1e-9;
static String s;
//variables end

static void read(){

   s=scan.next();

}
static void solve(){
	int l=s.length();

	int t=1,ans=1;

	for(int i=1;i<=l-1;i++){
		if(s.charAt(i)!=s.charAt(i-1)||t==5){
			ans++; t=1;
			}else t++;

	}

	System.out.println(ans);

}

public static void main(String[] args) {
  read();
  solve();
}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aeroui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] arr = in.next().toCharArray();
            int cnt = 0;
            int cur = ' ';
            int ans = 0;

            for (int i = 0; i < arr.length; ++i) {
                if (cnt == 0) {
                    cur = arr[i];
                    ++cnt;
                    continue;
                }

                if (arr[i] != cur) {
                    ++ans;
                    cnt = 1;
                    cur = arr[i];
                } else {
                    ++cnt;
                    if (cnt == 5) {
                        ++ans;
                        cnt = 0;
                    }
                }
            }

            out.println(ans + (cnt > 0 ? 1 : 0));
        }

    }
}

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner (System.in);

        String x = input.nextLine();
        int count = 1;
        byte s = 0;
        for (int i = 0; i < x.length()-1; i++) {

            if(x.charAt(i) == x.charAt(i+1)){
                s++;
            }else{
                s = 0;
                count++;
            }
            if(s == 5){
                s = 0;
                count++;
            }
        }
        System.out.println(count);
    }
}

import java.util.Scanner;
import java.util.Stack;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author abdu
 */
public class Main {
    public static void main(String[]args){
        int n =0;
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        Stack s = new Stack();
        for(int i = 0;str.length()>i ;i++){
        if (s.empty()){
            s.add(str.charAt(i));
        }
        else if(str.charAt(i) == s.peek()){
            s.add(str.charAt(i));
        }
        else{
            n++;
            s.clear();
            s.add(str.charAt(i));
        }
        if(s.size() == 5){
            s.clear();
            n++;
        }
    }
        if(!s.empty()){
            n++;
            s.pop();
            System.out.println(n);
        }
        else
            System.out.println(n);

    }
}

import java.util.ArrayList;
import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author bosha
 */
public class A137 {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        ArrayList<Character> arr = new ArrayList<Character>();
        String temp = s.nextLine();

        for (int i = 0; i < temp.length(); i++) {
            arr.add(temp.charAt(i));

        }

        char inhand;
        char nextHand;

        int visits = 0;
        int count = 0;

        for (int i = 0; i < arr.size(); i++) {

            if (i == arr.size() - 1) {
                visits++;
                break;
            }
            inhand = arr.get(i);
            nextHand = arr.get(i + 1);

            if (inhand == nextHand) {

                count++;

                if (count == 5) {
                    count = 0;
                    visits++;

                    continue;
                }

            } else {
                visits++;
                count = 0;
            }

        }

        System.out.println(visits);

    }
}

import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

public class a {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		String s = in.next();
		int n = s.length(), ans = 0;
		for(int l = 0, r = 0; l < n; l = r) {
			while (r < n) {
				if (s.charAt(r) == s.charAt(l)) r++;
				else break;
			}
			ans += (r - l + 4) / 5;
		}

		out.println(ans);
		out.close();
	}
}

/* Java Template */
class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CP{
	public static void main(String[] args){
		int ans = 0;
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = bf.readLine();
			char last = line.charAt(0);
			int buffer = 1;
//			for(int i=1;i<line.length();i++){
//				if(last != line.charAt(i)){
//					buffer=0;
//					ans++;
//				}
//				else {
//					buffer++;
//					if(buffer == 5){
//						buffer = 0;
//						ans++;
//					}
//				}
//				last = line.charAt(i);
//			}
//			ans++;

			int index = 1;
			while(index < line.length()){
				if(last != line.charAt(index)){
					buffer=0;
					ans++;
					last = line.charAt(index);
					buffer++;
					index++;
				}
				else{
					buffer++;
					if(buffer == 5){
						buffer=0;
						ans++;
						if((index+1)<line.length()){
							last = line.charAt(++index);
							buffer++;
						}
						index++;
						continue;
					}
					index++;
				}
			}
			if(buffer!=0) ans++;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(ans);
	}
}

import java.io.*;

public class main{

	public static void main(String args[])
	{
		BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));

		try
		{
			String sequence = inputReader.readLine();

			int count =0;
			boolean flag = true;

			for(int i=0;i<sequence.length();i++)
			{
				char current = sequence.charAt(i);

				for(int j=i;j<4+i && j < sequence.length()-1;j++)
				{
					if(sequence.charAt(j+1) != current)
					{
						count++;
						i = j;
						flag = false;
						break;
					}
				}
				if(flag == true)
				{
					i = i+4;
					count++;
				}
				flag = true;
			}

			System.out.println(count);
		}
		catch(IOException ioexcep)
		{
			/*
				Handle It
			*/
		}
	}
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/* Name of the class has to be "Main" only if the class is public. */
public class bbg
{
	public static int result;

public static ArrayList<Integer> [] graph;

public static int[]cats;

public static int vizitat[];
public static int x;
//public static HashMap<String, Integer> map2;

	public static void main (String[] args) throws java.lang.Exception
{

Scanner input=new Scanner(System.in);

HashMap<Integer, Integer> contor1= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> contor2= new HashMap<Integer, Integer>();

HashMap<Integer, Integer> map= new HashMap<Integer, Integer>();
HashMap<String, Integer> curatare= new HashMap<String, Integer>();
HashMap<String, Integer> combinari= new HashMap<String, Integer>();

	String str=input.next();

	int poz=0;
	int contor=0;
	int drum=0;

	while(poz<str.length()){

		contor=0;

		while(poz+1<str.length() && str.charAt(poz+1)==str.charAt(poz) && contor<4){

			contor++; poz++;

		//  System.out.println(poz+" "+contor+" "+drum);

		}

		drum++;
		poz++;

		//  System.out.println(poz+" "+contor+" "+drum);

	}

	System.out.println(drum);
}

		}

import java.util.Scanner;
public class Main
{
    public static void main(String[] args) throws Exception
    {
    	Scanner input = new Scanner(System.in);
		String n = input.next();
		int counter = 1;
		int atHand = 0;
		char temp = n.charAt(0);

		for(int i = 0;i < n.length();i++)
		{
			if(n.charAt(i) != temp || atHand == 5)
			{
				temp = n.charAt(i);
				++counter;
				atHand = 0;
			}
			++atHand;
		}
		System.out.println(counter);
    }
}

import java.util.Scanner;

public class PostcardsAndPhotos {

    public static void main(String[] args) {

        Scanner input = new Scanner (System.in);

        String s = input.next();

        int count = 1 ;

        char c = s.charAt(0);
        int temp = 1;

        for(int i = 1 ; i < s.length() ; i++)
        {
            if(s.charAt(i) != c || temp == 5)
            {
                count++;
                temp = 1;
                c = s.charAt(i);
            }
            else
                temp++;
        }

        System.out.println(count);
    }

}

// https://codeforces.com/problemset/problem/137/A

import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		Scanner read = new Scanner(System.in);

		String s = read.nextLine();

		final int MAX_NUMBER_OF_CARRIED_ITEMS = 5;
		int minNumberOfClosetVisits = 0;

		int i = 0;
		while (i < s.length()) {
			int numberOfCarriedItems = 1;
			i++;
			while (i < s.length() &&
				   s.charAt(i) == s.charAt(i-1) &&
				   numberOfCarriedItems < MAX_NUMBER_OF_CARRIED_ITEMS)
			{
				i++;
				numberOfCarriedItems++;
			}
			minNumberOfClosetVisits++;
		}

		System.out.println(minNumberOfClosetVisits);

		// Close scanner
		read.close();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class postcardandphoto {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=(br.readLine().trim());
        int c=0,v=0;
        s=s+"a";
        for(int i=0;i<s.length()-1;i++){
            if(s.charAt(i)=='C'){
                c++;
            if(!(c<5)||s.charAt(i+1)=='P'){
                v++;
                c=0;
            }}else{
            if(s.charAt(i)=='P')
                c++;
            if(!(c<5)||s.charAt(i+1)=='C'){
                v++;
                c=0;
            }}

        }if(c!=0)
            v++;
        System.out.println(v);

    }

}

import java.util.Scanner;

public class Postcards {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int i,sum,j,k;
        String s;
        while (input.hasNext()){
            s = input.nextLine(); sum = 0;
            int l = s.length();
            for (i=0; i<l; ){
                if (s.charAt(i) == 'C'){
                    j = i+5;
                    while (i<l && s.charAt(i) == 'C' && j>i){
                       // System.out.println(i);
                        i++;

                    }
                    //i--;
                    sum++;
                }
                else {
                    j = i+5;
                    while ( i<l && s.charAt(i) == 'P' && j>i){
                        i++;
                    }
                   // i--;
                    sum++;
                }
            }
            System.out.println(sum);
        }
    }
}

import java.util.Scanner;
public class Polycarpus {
  public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String n = s.next();
        int times = 1;
        int carried_item = 1;
        for(int  i = 1; i < n.length(); i++)
        {
        if(n.charAt(i) == n.charAt(i - 1) && carried_item < 5)
            ++carried_item;
        else
            {
            ++times;
            carried_item = 1;
                }
        }
    System.out.println(times);
    s.close();
    }
}

		import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

		/*07:05:45PM

		String x =sc.next();
		char inp [] = x.toCharArray();
			SimpleDateFormat displayFormat = new SimpleDateFormat("HH:mm");
			SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
			Date date = parseFormat.parse(x.substring(0, 5)+" "+x.substring(8, 10));
			System.out.println(displayFormat.format(date)+":"+x.substring(6, 8));
		*/

	public class Main {
		public static boolean isPrime(int i )
		{

			for (int j = 2; j <i; j++) {
					if(i%j==0)return false;
			}
			return true;
		}
	public static void main(String args[]) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		char arr [] = sc.next().toCharArray();
		int res=0;
		int cnt=0;
		if(arr.length==0){System.out.println(0);return;}
		int current=arr[0]=='C'?1:0;
		boolean last=false;
		char c='a';
		for (int i = 0; i < arr.length; i++) {
			if(i==arr.length-1)
			{
				if(c=='a')res=1;
				else if(arr[i]==c)
				{
					cnt++;
					if(cnt<=5)
						res+=1;

					else if(cnt%5==0)res+=cnt/5;
					else res+=cnt/5+1;
					last=true;
				}
				else
				{
					res++;
					last=true;
				}
			}
			else {
			if(arr[i]==arr[i+1])cnt++;
			else
			{
				cnt++;
				if(cnt%5==0)res+=cnt/5;
				else res+=cnt/5+1;
				cnt=0;
			}
			}
			c=arr[i];
		}
		System.out.println(res);

	}
	}

		class Pair implements Comparable<Pair>
		{
			public int  x  ,y ,z ;
			Pair(int a , int b , int l)
			{
				x=a;y=b;z=l;
			}
			@Override
			public boolean equals(Object obj) {
				// TODO Auto-generated method stub
				return x==((Pair)(obj)).x && y==((Pair)obj).y;
			}

			@Override
			public int hashCode() {
				// TODO Auto-generated method stub
				return 6*x +8*y;
			}
			@Override
			public int compareTo(Pair o) {
				// TODO Auto-generated method stub
				return x*o.y - y*o.x;
			}

		}

		 class Scanner
		{
			StringTokenizer st;
			BufferedReader br;

			public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

			public String next() throws IOException
			{
				while (st == null || !st.hasMoreTokens())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			}

			public int nextInt() throws IOException {return Integer.parseInt(next());}

			public long nextLong() throws IOException {return Long.parseLong(next());}

			public String nextLine() throws IOException {return br.readLine();}

			public double nextDouble() throws IOException
			{
				String x = next();
				StringBuilder sb = new StringBuilder("0");
				double res = 0, f = 1;
				boolean dec = false, neg = false;
				int start = 0;
				if(x.charAt(0) == '-')
				{
					neg = true;
					start++;
				}
				for(int i = start; i < x.length(); i++)
					if(x.charAt(i) == '.')
					{
						res = Long.parseLong(sb.toString());
						sb = new StringBuilder("0");
						dec = true;
					}
					else
					{
						sb.append(x.charAt(i));
						if(dec)
							f *= 10;
					}
				res += Long.parseLong(sb.toString()) / f;
				return res * (neg?-1:1);
			}

			public boolean ready() throws IOException {return br.ready();}

		}

import java.io.BufferedInputStream;
import java.util.Collections.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.TreeMap;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner scanner=new Scanner(new BufferedInputStream(System.in));
		String t=scanner.nextLine();
		t+=" ";
		int total=0;
		for (int i=0;i<t.length()-1;){
			if (t.charAt(i)!=t.charAt(i+1)){
				total++;i++;
			}
			else{
				int temp=1;
				total++;
				while (temp<5&&t.charAt(i)==t.charAt(i+1)){
					temp++;i++;
				}
				i++;
			}
		}
		System.out.println(total);
	}
}

import java.util.*;
public class Main {
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    int result = 1;
    int co = 1;
    char pre = n.charAt(0);
    for(int i=1; i<n.length(); i++){
        if(n.charAt(i) == pre){
            co ++;
        }
        if(co > 5){
            result ++;
            co = 1;
        }
        if (n.charAt(i) != pre){
            result ++;
            co = 1;
            pre = n.charAt(i);
        }
    }
    System.out.println(result);

}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception{
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        String s = inp.readLine();
        int c = 1;
        int count = 0;

        for(int i = 0; i < s.length()-1; i++){
            if(s.charAt(i) == s.charAt(i+1)){
                if(c < 5)
                    c++;
                else{
                    c = 1;
                    count++;
                }
            }
            else{
                    c = 1;
                    count++;
            }
        }
        count++;
        System.out.println(count);
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;

public class CodeForces{
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer token;
    public static void main(String args[])throws Exception{
        String input = reader.readLine();
        ArrayList<Lol> list = new ArrayList<Lol>();
        list.add(new Lol(input.charAt(0), 1));
        Lol node = list.get(0);
        for (int i = 1; i < input.length(); i++) {
            char x = input.charAt(i);
            boolean ada = false;
            if(x == node.jenis){
                ada = true;
                node.count++;
            }
            if(!ada){
                node = new Lol(input.charAt(i),1);
                list.add(node);
            }
        }
        Iterator<Lol> itr = list.iterator();
        int counter = 0;
        while(itr.hasNext()){
            counter += Math.ceil(1.0*(itr.next().count)/5);
        }
        System.out.println(counter);

    }

    public static void token()throws Exception{
        token = new StringTokenizer(reader.readLine());
    }

    public static int nextInt() throws Exception{
        return Integer.parseInt(token.nextToken());
    }

    public static int readInt() throws Exception{
        return Integer.parseInt(reader.readLine());
    }
}

class Lol{
    public char jenis;
    public int count;

    public Lol(char x, int count) {
        this.jenis = x;
        this.count = count;
    }

}

import java.util.*;

public class JavaApplication3 {
    public static void main(String[] args) {
        Scanner inStr = new Scanner(System.in);
        String str = inStr.nextLine();
        int result = 1, count = 1;
        for (int idx = 1; idx < str.length(); idx++) {
            if (str.charAt(idx) == str.charAt(idx-1) && count < 5)
                count++;
            else {
                count = 1; result++;
            }
        }
        System.out.println(result);
    }
}

//package hellooos;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import org.omg.Messaging.SyncScopeHelper;

public class rythm {
static int maxSofar;
static int maxElem;
	public static boolean prime(int x){
		for (int i = 2; i < x; i++) {
			if(x%i==0)
				return false;
		}
		return true;
	}
public static void main(String[] args) throws IOException {
	BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
String input=in.readLine();
int countSofar=1;
char elem=input.charAt(0);
int trips=1;

for (int i = 1; i < input.length(); i++) {
	if(countSofar==5||elem!=input.charAt(i)){
		trips++;
		countSofar=0;
		elem=input.charAt(i);
	}
	if(elem==input.charAt(i))
		countSofar++;

}
System.out.println(trips);
}
}

import java.util.Scanner;

public class PostcardsAndPhotos {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int ans = 0,idx = 0;
        while (idx < s.length()) {
            char c = s.charAt(idx);
            idx++;
            int cnt = 1;
            while (idx < s.length() && s.charAt(idx) == c && cnt < 5) {
                idx++;
                cnt++;
            }
            ans++;
        }
        System.out.println(ans);
    }//psvm
}//class

import java.util.Scanner;

public class Postcards {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		int v = 4;
		int i = 0;
		while (i < s.length()) {
			char c = s.charAt(i);
			i++;
			while (v > 0 && i < s.length()) {

				char c2 = s.charAt(i);
				if (c2 == c) {
					v--;
					i++;
				} else
					break;
			}
			count++;
			v = 4;
		}
		System.out.println(count);
	}
}

import java.util.Scanner;

public class Polycarpus {

      public static void main(String[] args) {

            Scanner s = new Scanner(System.in);
            String pat = s.nextLine();
            int len = pat.length();

            int index = 0;
            int count = 0;
            while (index < len) {
                char c = pat.charAt(index);
               // System.out.println(c + ":index ");
                index++;
                int in_hands = 1;
                boolean b = true;
                while (b && index < len && in_hands < 5) {
                  //  System.out.println(pat.charAt(index));
                    if (c == pat.charAt(index)) {
                        in_hands++;
                        index++;
                    } else {
                        b = false;
                    }
                }
                count++;
            }
            System.out.println(count);
      }
}

import java.util.*;
import java.io.*;

public class practice {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        char carrying = ' ';
        int capacity = 0;
        int count = 0;
        for(char c : str.toCharArray()) {
            if(carrying != c) {
                if(capacity != 0) {
                    count++;
                }
                carrying = c;
                capacity = 1;
            } else {
                capacity++;
                if(capacity > 4) {
                    count++;
                    capacity = 0;
                    carrying = ' ';
                }
            }
        }
        if(capacity != 0) {
            count++;
        }
        System.out.println(count);
        /*StringBuilder sb = new StringBuilder();
        for (int i=0; i<a; i++){
            sb.append(nums[i]);
            if(i != a - 1) {
                sb.append(' ');
            }
        }
        System.out.println(sb.toString());*/
    }
}

import java.util.Scanner;

public class Postcardsandphotos {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String p = scan.next();
        String s[] = p.split("C", -1);
        String k[] = p.split("P", -1);
        int r = 0;
        for (int i = 0; i < s.length; i++) {
            r += Math.ceil(s[i].length() / 5.0);

        }
        for (int i = 0; i < k.length; i++) {
            r += Math.ceil(k[i].length() / 5.0);
        }
        System.out.println(r);
    }
}

import java.util.*;
import java.io.*;
import java.math.*;

public class Practica_1 {

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        String ln = in.nextLine();
        String comienzo = ln.charAt(0) + "", cdn = "";
        ArrayList<String> V = new ArrayList<String>();
        for (int i = 0; i < ln.length(); i++) {
            if ((ln.charAt(i) + "").equals(comienzo)) {
                cdn += ln.charAt(i);
            } else {
                V.add(cdn);
                comienzo = ln.charAt(i) + "";
                cdn = comienzo;
            }
        }
        if (cdn.length() > 0) {
            V.add(cdn);
        }
        int rpta = 0;
        for (int i = 0; i < V.size(); i++) {
            if (V.get(i).length() > 5) {
                int div = V.get(i).length() / 5;
                int res = V.get(i).length() % 5;
                rpta += div;
                if (res > 0) {
                    rpta++;
                }
            } else{
                rpta++;
            }
        }
        System.out.println(rpta);
    }

    static void pr(Object... ob) {
        System.out.println(Arrays.deepToString(ob).replace("],", " ],\n"));
    }
}

import java.lang.*;
import java.io.*;
import java.util.*;

public class photos {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {

	public void solve(InputReader in, PrintWriter out) {
		String s = in.next();
		int len = s.length();
		int i = 0, j, k;
		int ans = 0;

		while (i < len) {
			j = i++;
			while (i<len && s.charAt(i)==s.charAt(j))
				++i;
			ans += (i-j+4)/5;
		}
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PostcardsAndPhotos {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] letter = br.readLine().toCharArray();
        int times = 1, count = 1;

        for (int i = 1; i < letter.length; i++) {
            if (letter[i] != letter[i - 1]) {
                times++;
                count = 1;
            } else {
                count++;
                if (count > 5) {
                    count = 1;
                    times++;
                }
            }
        }

        System.out.println(times);
    }

}

import java.util.*;

public class p137A {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();

		char last = s.charAt(0);
		int count = 1, run = 1;
		for(int i=1; i<s.length(); ++i) {
			if(s.charAt(i) == last) {
				if(run == 5) {
					++count;
					run = 1;
				}
				else ++run;
			}
			else {
				++count;
				run = 1;
				last = s.charAt(i);
			}
		}

		System.out.println(count);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class ProblemA
{

	public static void main(String[] args) throws IOException
	{
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String num[]=bf.readLine().split(" ");
		String A=num[0];

		int contDef=0;
		int contTemp=0;

		for (int i = 0; i < A.length()-1; i++)
		{

			if(A.charAt(i)!=A.charAt(i+1))
			{
				contTemp=0;
				contDef++;
			}
			else
			{
				contTemp++;
				if(contTemp==5)
				{
					contDef++;
					contTemp=0;
				}
			}
		}

		contDef++;
		System.out.println(contDef);
	}
}

import java.util.Scanner;

public class Postcardsandphotos {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        String s=in.nextLine();
        int c=0;
        int i=0,d=0;
        while(i<s.length())
        {
            while(i<s.length()&&s.charAt(i)=='C' && c<5)
            {
                c++;
                i++;
            }
            if(c>0)
            {
                d+=1;
                c=0;
            }
            while(i<s.length()&&s.charAt(i)=='P' && c<5)
            {
                i++;
                c++;
            }
           if(c>0)
            {
                d+=1;
                c=0;
            }
        }
        System.out.println(d);
    }
}

import java.io.*;
import java.util.*;
public class Main {

    public static void main(String[] args) {
        InputReader sc = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        Random gen = new Random();
        int test = 1;//sc.nextInt();
        while(test-->0) {

           char [] ar  = sc.nextLine().toCharArray();
           ArrayList<Integer> l = new ArrayList<>();
           int len = 0;
           for(int i=0;i<ar.length;i++)
           {
               if(ar[i]=='C')
               {
                   len++;
               }
               else
               {
                   if(len>0)
                    l.add(len);
                   len = 0;
               }
           }
           if(len!=0)
               l.add(len);
           len = 0;
            for(int i=0;i<ar.length;i++)
            {
                if(ar[i]=='P')
                {
                    len++;
                }
                else
                {
                    if(len>0)
                        l.add(len);
                    len = 0;
                }
            }
            if(len!=0)
                l.add(len);

          //  pw.println(l);
            long ans = 0;
            for(int i : l)
            {
                ans+= (i+4)/5;
            }
            pw.println(ans);

        }
        pw.close();

    }

    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

        public InputReader(InputStream st) {
            this.stream = st;
        }

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int [] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public static int[] shuffle(int[] a, Random gen)
        { for(int i = 0, n = a.length;i < n;i++)
        { int ind = gen.nextInt(n-i)+i;
            int d = a[i];
            a[i] = a[ind];
            a[ind] = d;

        }
            return a;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

    }

}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A137 {
  static FastScanner in;
  static FastWriter out;

  public static void main(String[] args) throws IOException {
    in = new FastScanner(System.in);
    out = new FastWriter(System.out);

    char[] a = in.next().toCharArray();

    char last = ' ';
    int ans = 0;
    int cnt = 0;
    for (char c : a) {
      if (c != last) {
        ans += (cnt + 4) / 5;
        cnt = 1;
      } else {
        cnt++;
      }
      last = c;
    }
    ans += (cnt + 4) / 5;
    out.println(ans);
    out.close();
  }

  static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(InputStream in) {
      br = new BufferedReader(new InputStreamReader(in));
      st = new StringTokenizer("");
    }

    public FastScanner(File f) throws IOException {
      br = new BufferedReader(new FileReader(f));
      st = new StringTokenizer("");
    }

    public int nextInt() throws IOException {
      return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
      return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
      return Double.parseDouble(next());
    }

    public String next() throws IOException {
      if (st.hasMoreTokens()) return st.nextToken();
      st = new StringTokenizer(br.readLine());
      return next();
    }
  }

  static class FastWriter extends PrintWriter {
    public FastWriter(OutputStream out) throws IOException {
      super(new BufferedWriter(new OutputStreamWriter(out)));
    }

    public FastWriter(File f) throws IOException {
      super(new BufferedWriter(new FileWriter(f)));
    }
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class CF137A {
    public static void main(String[] args) {
        FastReader input = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);

        String s = input.nextLine();
        char[] arr = s.toCharArray();
        int items = 0;
        int ans = 0;
        int pos = 0;
        if(arr.length == 1)
            ans = 1;
        for(int i = 0;i < arr.length-1;i++){
            if(i == arr.length-2){
                if(arr[i] == arr[i+1]){
                    items++;
                    if(items == 5){
                        ans++;
                        items = 0;
                    }
                    items++;
                    ans++;
                    break;
                }
                else {
                    ans += 2;
                    break;
                }
            }

            if(arr[i] == arr[i+1]){
                items++;
            }
            else{
                items++;
                ans++;
                items = 0;
            }
            if(items == 5){

                ans++;
                items = 0;
            }
        }
        pw.println(ans);

        pw.flush();
        pw.close();
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Task task = new Task();
		task.getData();
		task.solve();
		task.printAnswer();
	}
}

class Task {
	String sequence;

	StringBuilder answer = new StringBuilder();

	public void getData() {
		Scanner console = new Scanner(System.in);

		sequence = console.next();

		console.close();
	}

	public void solve() {
		int operationCount = 0;
		for (int i = 0; i < sequence.length();) {
			int counter = 0;
			int it = i;
			for (; it < sequence.length(); ++it) {
				if (sequence.charAt(it) != sequence.charAt(i)) {
					break;
				}
				++counter;
			}
			operationCount += (counter + 5 - 1) / 5;
			i = it;
		}
		answer.append(operationCount);
	}

	public void printAnswer() {
		System.out.print(answer);
	}
}

class Point {
	Integer x;
	Integer y;

	Point(Integer x, Integer y) {
		this.x = x;
		this.y = y;
	}
}

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CF {
    public static StringTokenizer tokenizer;
    public static BufferedReader reader;
    public static PrintWriter writer;
    public static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new PrintWriter(new OutputStreamWriter(System.out));
//        try {
//            reader = new BufferedReader(new InputStreamReader(new FileInputStream("ladder.in")));
//            writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream("ladder.out")));
//        } catch (IOException e) {
//            System.out.println(e);
//            System.exit(1);
//        }
    }
    public static String nextToken() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                System.out.println(e);
                System.exit(1);
            }
        }
        return tokenizer.nextToken();
    }
    public static int nextInt() {
        return Integer.parseInt(nextToken());
    }
    public static long nextLong() {
        return Long.parseLong(nextToken());
    }
    public static byte nextByte() {
        return Byte.parseByte(nextToken());
    }
    public static double nextDouble() {
        return Double.parseDouble(nextToken());
    }
    public static float nextFloat() {
        return Float.parseFloat(nextToken());
    }
    public static short nextShort() {
        return Short.parseShort(nextToken());
    }
    public static void close() {
        try {
            reader.close();
            writer.flush();
            writer.close();
        } catch (IOException e) {
            System.out.println(e);
            System.exit(1);
        }
    }
    public static void main(String[] args) {
        init();
        solve();
        close();
    }
    public static void solve() {
        String s = nextToken();
        int cnt = 1;
        int temp = 1;
        for (int i = 1; i < s.length(); i++) {

            if (s.charAt(i) != s.charAt(i-1) || temp == 5) {
                cnt++;
                temp = 1;
            } else {
                temp++;
            }
        }
        writer.print(cnt);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

//633

public class B {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String s = sc.nextLine();
		int ans = 0;
		int c = 1;
		/*String ss = "";
		char f = s.charAt(0);
		for(int i = 1;i < s.length();i++){
			if(f == s.charAt(i))
				c++;
			else {
				ss += c+""+f;
				f = s.charAt(i);
				c = 1;
			}
		}
		ss += c+""+f;
		pw.println(ss);
		String num = "";
		for(int i = 0;i < ss.length();i++){
			if(Character.isDigit(ss.charAt(i))){
				num += ss.charAt(i);
			}
			else {
				ans += Integer.parseInt(num) <= 5 ? 1: (Integer.parseInt(num)/5) + Integer.parseInt(num) % 5;
				num = "";
			}
		}*/

		for(int i = 1;i < s.length();i++){
			if(s.charAt(i) != s.charAt(i - 1)){
				//int x = (c <= 5)? 1: (c/5) + (c%5);
				ans += Math.ceil((c / 5.0));
				c = 1;
			}
			else
				c++;
			if(i == s.length() - 1){
				//ans += c <= 5? 1: (c/5) + (c%5);
				//int x = (c <= 5)? 1: (c/5) + (c%5);
				ans += Math.ceil(c / 5.0);
			}
		}
		if(s.length() == 1)
			ans++;
		pw.println(ans);
		pw.close();
	}

	static class MyScanner {
		StringTokenizer st;
		BufferedReader br;

		public MyScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.NoSuchElementException;
import java.util.Objects;

public class PostcardsAndPhotos {

    public static void main(String[] args) {
        Reader read = new Reader();

        String s = read.nextStr();

        int c = 0;
        int i = 0;
        int j = 0;

        while(i<s.length()) {
            while(i < s.length()-1 && s.charAt(i+1) == s.charAt(i) && j < 4) {
                i++;
                j++;
            }
            c++;
            i++;
            j=0;
        }

        System.out.print(c);
    }

    private static class Reader {

        private final BufferedReader reader;
        private final String separator;
        private String ln;
        private String[] tokens;
        private int ptr;

        Reader(String separator, InputStream input) {
            this.reader = new BufferedReader(new InputStreamReader(input));
            this.separator = separator;
            this.ptr = -1;
        }

        Reader(String separator) { this(separator, System.in); }

        Reader() { this(" "); }

        String nextStr(){
            if (Objects.isNull(ln)) {
                try {
                    ln = reader.readLine();
                } catch (IOException e) {
                    System.out.println(e.getMessage());
                }
                if (Objects.nonNull(ln)) {
                    tokens = ln.split(separator);
                    ptr = 0;
                } else {
                    throw new NoSuchElementException("no next element");
                }

            } else if (ptr == tokens.length) {
                ln = null;
                tokens = null;
                ptr = -1;
                return nextStr();
            }

            return tokens[ptr++];
        }

        int nextInt() { return Integer.parseInt(nextStr()); }

        long nextLong() { return Long.parseLong(nextStr()); }

        double nextDouble() { return Double.parseDouble(nextStr()); }
    }
}

import java.util.*;

public class PostcardsAndPhotos_A {
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		String str = s.nextLine().trim() + "A";
		s.close();

		int ans = 0;
		char current = str.charAt(0);
		int num = 1;

		for (int i=1; i<str.length(); i++)
		{
			char here = str.charAt(i);
			if (here != current || i == str.length() - 1)
			{
				ans += (num + 4) / 5;
				num = 1;
				current = here;
			}
			else num++;
		}

		System.out.println(ans);
	}
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//package codeforces_98_beta;

import java.util.Scanner;

/**
 *
 * @author Xeyyam
 */
public class A {

    public void run(){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        char cur = s.charAt(0);
        int k = 1;

        for(int i = 1 ; i<s.length() ;){
            while(i<s.length() && s.charAt(i)==cur && k<5){
                k++;
                i++;
            }
            ans++;
            if( i  < s.length() )
            cur = s.charAt(i);
            k = 0;

        }
        if( s.length() == 1 )
            System.out.println(1);
        else
        System.out.println(ans);
    }

    public static void main(String args[]){
        new A().run();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class PostcardsAndPhotos {

	public static void main(String[] args) throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		sc = new StringTokenizer(br.readLine());
		String s = nxtTok();
		int t = 0;
		for (int i = 0; i < s.length(); i++) {
			int c = 1;
			while (i + 1 < s.length() && s.charAt(i) == s.charAt(i + 1)) {
				c++;
				i++;
			}
			t += c / 5 + (c % 5 == 0 ? 0 : 1);
		}
		out.println(t);
		br.close();
		out.close();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));

	static StringTokenizer sc;

	static String nxtTok() throws IOException {
		while (!sc.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null)
				return null;
			sc = new StringTokenizer(s.trim());
		}
		return sc.nextToken();
	}

	static int nxtInt() throws IOException {
		return Integer.parseInt(nxtTok());
	}

	static long nxtLng() throws IOException {
		return Long.parseLong(nxtTok());
	}
}

import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    String line = scan.nextLine();
    int count = 0;
    char last = ' ';
    int curcount = 0;
    for (int i = 0; i < line.length(); i++)
    {
      if (line.charAt(i) == last)
      {
        curcount++;
        if (curcount == 6)
        {
          curcount = 1;
          count++;
        }
      }
      else if (line.charAt(i) != last)
      {
        last = line.charAt(i);
        count++;
        curcount = 1;
      }
    }
    System.out.println(count);
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Postcards {
    public static void main(String args[]) throws IOException
    {
        BufferedReader br;
        br = new BufferedReader(new InputStreamReader(System.in));
        String res = br.readLine();
        //String res = "CCCCCCCCCC";
        int i=0;
        int c=0;
        d: while(i<res.length())
        {
            boolean check = true;
            char comp = res.charAt(i);
            for(int j=i; j<i+5; j++)
            {
                if(j>=res.length())
                {
                    c++;
                    break d;
                }
                if(res.charAt(j)!=comp)
                {
                    c++;
                    i=j;
                    check = false;
                    break;
                }

            }
            if(check)
            {
                c++;
                i+=5;
            }
        }
        System.out.println(c);
    }
}

public class Main {public static void main(String[] args) {System.out.println(new java.util.Scanner(System.in).nextLine().replaceAll("C{1,5}","X").replaceAll("P{1,5}","Y").length());}}

import java.util.Scanner;

public class A137 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.next()+"X";
        char last = s.charAt(0);
        int count = 0;
        int answer = 0;
        for (int i=0; i<s.length(); i++) {
            char c = s.charAt(i);
            if (last == c) {
                count++;
                if (count == 6) {
                    answer++;
                    count = 1;
                }
            } else {
                answer++;
                last = c;
                count = 1;
            }
        }
        System.out.println(answer);
    }

}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String in = new Scanner(System.in).nextLine();
        int hand = 0; int res = 0;
        char handType = '#';
        for(int i=0; i<in.length(); i++) {
            char c = in.charAt(i);
            if (handType == '#')
                handType = c;
            if (c == handType) {
                hand++;
            } else {
                res++;
                hand = 1;
                handType = c;
            }
            if (hand == 5) {
                res++;
                hand = 0;
                handType = '#';
            }
        }
        res += (hand > 0) ? 1 : 0;
        System.out.println(res);
    }
}

import java.io.*;
import java.util.*;

public class p136c {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int count = 0;
        int temp = 1;
        int l = str.length();
        for (int i = 0; i < l - 1; i++) {
            if (str.charAt(i) == str.charAt(i + 1)) {
                temp++;
            } else {
                if (temp % 5 == 0) count += (temp / 5);
                else count += (temp / 5 + 1);
                temp = 1;
            }
        }
        if (temp % 5 == 0) count += (temp / 5);
        else count += (temp / 5 + 1);
        System.out.println(count);
    }
}

import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class test implements Runnable{

    public void solve() throws IOException{
        String str = nextToken();
        char ch;
        int ret = 0;
        for(int i=0; i<str.length(); i++){
            ch = str.charAt(i);
            i++;
            for(int j=0; j<4 && i<str.length(); j++){
                if(str.charAt(i) != ch)break;
                i++;
            }
            ret++;
            i--;
        }
        writer.println(ret);
    }

    public static void main(String args[]) throws IOException{
        new test().run();
    }
    PrintWriter writer;
    StringTokenizer tokenizer;
    BufferedReader reader;

    public void run(){
        try{
            reader = new BufferedReader(new InputStreamReader(System.in));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException{
        while(tokenizer == null || !tokenizer.hasMoreTokens()){
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    double nextDouble() throws IOException{
        return Double.parseDouble(nextToken());
    }

    int nextInt() throws IOException{
        return Integer.parseInt(nextToken());
    }

 }

import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		String s = new Scanner(System.in).next()+" ";
		int cnt = 1;
		int ans = 0;
		for (int i = 1; i < s.length(); i++) {
			if (cnt == 5 || s.charAt(i) != s.charAt(i-1)){
				ans++;
				cnt = 1;
			}else cnt++;
		}
		System.out.println(ans);
	}
}

import java.io.*;
import java.util.*;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pr = new PrintWriter(System.out, true);

        String s = sc.next();
        int n = s.length();
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            int r = i;
            while (r + 1 < n && r + 1 < i + 5 && s.charAt(r + 1) == s.charAt(i)) ++r;
            ++ans;
            i = r;
        }
        System.out.printf("%d", ans);
    }
}

import java.util.Scanner;

public class A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String input = in.next();
        String s = input + ".";
        int counter1 = 0;
        int counter2 = 0;
        for (int i = 1; i < s.length(); i++) {

            if (s.charAt(i) != s.charAt(i - 1)) {
                counter1++;
                counter2 = 0;
            } else {
                counter2++;
                if (counter2 == 5) {
                    counter1++;
                    counter2 = 0;
                }
            }
        }
        System.out.println(counter1);
    }
}

import java.util.*;

public class cf137a {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next().trim();
		int ret = 1;
		int count = 1;
		for(int i=1; i<s.length(); i++) {
			if(s.charAt(i)==s.charAt(i-1)) count++;
			else {
				count = 1;
				ret++;
			}
			if(count > 5) {
				count = 1;
				ret++;
			}
		}
		System.out.println(ret);
	}
}

import java.util.*;
// warm-up
public class PostCardsAndPhotos {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n=0,c=1;
		char p='.';
		for (char ch : sc.next().toCharArray()) {
			if (p==ch && c<5) c++;
			else { c=1; n++; }
			p=ch;
		}
		System.out.println(n);
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

}

import java.util.Scanner;

public class problemA {
    private static final Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int t = 1;
//        t = in.nextInt();
        while (t != 0) {
            solve();
            t--;
        }
    }

    public static void solve() {
        String s = in.nextLine();
        long ans = 0, count = 1;
        for (int i = 1; i < s.length(); ++i) {
            if (s.charAt(i) != s.charAt(i - 1)) {
                if (count % 5 != 0) {
                    ans += count / 5 + 1;
                } else {
                    ans += count / 5;
                }
                count = 1;
            } else {
                count++;
            }
        }
        if (count % 5 != 0) {
            ans += count / 5 + 1;
        } else {
            ans += count / 5;
        }
        System.out.println(ans);
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner inputReader = new Scanner(System.in);
        String inputString = inputReader.nextLine();
        int count = 0;
        int answerCount = 0;
        EventList eList = new EventList();
        eList.Events.add(new Event(inputString.charAt(0), 1));
        for (int i = 1; i < inputString.length(); i++) {
            if (inputString.charAt(i) == eList.Events.get(count).Type) {
                eList.Events.get(count).length++;
            } else {
                eList.Events.add(new Event(inputString.charAt(i), 1));
                count++;
            }

        }
        while (eList.Events.size() > 0) {
            if (eList.Events.get(0).length > 5) {
                eList.Events.get(0).length -= 5;
                answerCount++;

            } else {
                eList.Events.remove(0);
                answerCount++;
            }
        }
        System.out.println(answerCount);

    }

}
class Event {
    public int length;
    public char Type;

    public Event(char Type, int length) {
        this.length = length;
        this.Type = Type;
    }

}

class EventList {

    // These variables are static because you don't need multiple copies
    // for sorting, as they have no intrinsic state.
    static private Comparator<Event> ascLocation;

    // We initialize static variables inside a static block.
    //1. Interface
    static {
        ascLocation = new Comparator<Event>() {
            @Override
            public int compare(Event p1, Event p2) {
                return Integer.compare(p1.length, p2.length);
            }
        };

    }

    //2.Property

    ArrayList<Event> Events = new ArrayList<Event>();

    //3. Method
    //a. Set /Get
    //b. General Function(Method>

    public ArrayList<Event> GetEventss() {
        return this.Events;
    }

    EventList() {

    }

    /*public Book[] getBooks() {
        return books;
    } */

    public void sortbylocation() {
        Collections.sort(Events, ascLocation);
    }

    public EventList(ArrayList<Event> oEvents) {
        this.Events = oEvents;
    }
}

/*
    @Test
    public void sortBooks() {
        Event[] Events = {
                new Event(0, 100, "S"),
                new Event(1, 100, "E")
        };

        // 1. sort using Comparable
        Arrays.sort(Events);
        System.out.println(Arrays.asList(Events));

        // 2. sort using comparator: sort by id
        Arrays.sort(Events, new Comparator<Events>() {
            @Override
            public int compare(Event o1, Event o2) {
                return (o1.Location - o2.Location);
            }
        });
        System.out.println(Arrays.asList(Events));
    }
*/

import java.util.*;

public class Postcards_nd_photos_Takua {

	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {

    String str=in.next();

    int count=1;
    int visit=1;
    if(str.length()!=1)   // if string contains more than 1 characters
    {

    for(int i=1; i<str.length();i++)
    {
    	if(str.charAt(i-1)==str.charAt(i)&&count<5)// if 2 characters equal and count of equal charaters less than 5,
    		count++;                                // then increase count

    	else if (count >=5)  // if count equal to 5, then reset count to 1 and start counting again a
    	{
    		count=1;
    		visit++;         //nd increse number of visits by 1
    	}
    	else if(str.charAt(i-1)!=str.charAt(i))// if prevcharacter
    	{   count=1;
    		visit++;
    	}

    }//end for

    }//end if

    System.out.println(visit);
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class CodeForces {
    public static void main(String[] args) throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        String input=in.readLine();
        int count=0;
        for(int i=0; i<input.length(); i++)
        {
            char cur=input.charAt(i);
            int j=i+1;
            while(j<input.length() && input.charAt(j)==cur && j-i!=5)
            {
                j++;
            }
            count++;
            i=j-1;
        }
        out.println(count);
        out.close();

    }
}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author codeKNIGHT
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
     String s=in.next();
        int c=1,t=1;
        char ch=s.charAt(0);
        for(int i=1;i<s.length();i++)
        {
            if(t==5)
            {
                c++;
                t=0;
            }
            if(s.charAt(i)==ch)
                t++;
            else
            {
                ch=s.charAt(i);
                c++;
                t=1;
            }

        }
        out.println(c);

	}
}

import java.math.*;
import java.util.*;

public class CF {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        String n = in.next();

        int c = 0;
        int p = 0;
        int trips = 0;

        for(int i = 0; i < n.length(); i++)
        {
            if(n.charAt(i) == 'C')
            {
                if(p > 0)
                {
                    trips++;
                    p = 0;
                    c=1;
                }
                else
                {
                    c++;
                }
            }
            else
            {
                if(c > 0)
                {
                    trips++;
                    c = 0;
                    p=1;
                }
                else
                {
                    p++;
                }
            }
            if(c == 5 || p == 5)
            {
                c = p = 0;
                trips++;
            }
        }
        trips += c + p;
        System.out.print(trips);
    }
}

//137/A

import java.util.Scanner;
public class Main {
    public static void main(String[]args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int count = 0;
        int c = 1;

        for (int i = 1 ; i < s.length(); i++) {

            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'C')) {
                c++;
                continue;
            }

            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'P')) {
                if (c % 5 == 0) {
                    count += 2*(c/5);
                } else {
                    count += 2*((c/5)+1);
                }
                c = 1;
            }// end of if-condition
        }// end of the for loop (i = 0)
        if (c > 1) {
            if (c % 5 == 0) {
                count += (c/5);
            } else {
                count += ((c/5)+1);
            }
        } else {
            if (s.charAt(s.length()-1) == 'C') count++;
        }

        if (s.charAt(0) == 'P') count++;
            System.out.println(count);

    }//end of main method
}//end of class

public class Solution {

  public static void main(String[] args) throws Exception {
    int count = 0, type = 0, result = 0;
    for (int c = System.in.read(); c != -1; c = System.in.read()) {
      if (type == 0 || c == type) {
        type = c;
        if (++count == 5) {
          count = 0;
          result++;
          type = 0;
        }
      } else {
        count = 1;
        result++;
      }
      type = c;
    }
    if (count != 0)
      result++;
    System.out.println(result);
  }
}

import java.util.Scanner;
import java.util.Stack;

/**
 *
 * @author abdu
 */
public class Main {
    public static void main(String[]args){
        int num = 0;
        int n =1;
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        Stack s = new Stack();
        for(int i = 0;str.length()>i ;i++){
        if (s.empty()){
            s.add(str.charAt(i));
            num = 1;
        }
        else if(str.charAt(i) == s.peek()){
            s.add(str.charAt(i));
            num++;
            if(num == 5){
                n++;
                s.pop();
            }
        }
        else{
            n++;
            s.pop();
            s.add(str.charAt(i));
            num =1;
        }
    }
        System.out.println(n);
    }
}

public class Solution {

  public static void main(String[] args) throws Exception {
    int count = 0, type = 0, result = 0;
    for (int c = System.in.read(); c != -1; c = System.in.read()) {
      if (type == 0) {
        count = 1;
        type = c;
      } else if (type == c) {
        if (++count == 5) {
          count = 0;
          result++;
          type = 0;
        }
      } else {
        count = 1;
        result++;
        type = c;
      }
    }
    if (count != 0)
      result++;
    System.out.println(result);
  }
}

import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Scanner;

//http://www.codeforces.com/contest/137/problem/A
public class A137 {
	public static void main(String[] args) throws IOException {
		solveTriangularNumbers();
	}
	public static void solveTriangularNumbers() throws IOException{
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		char a[] = scan.nextLine().toCharArray();

		int counter = 0;
		int sameCount = 1;
		for (int i = 1; i < a.length; i++) {
			if(a[i-1] != a[i]){
				counter++;
				sameCount = 1;
			}else {
				sameCount++;
				if(sameCount == 5){
					sameCount = 0;
					counter++;
				}
			}
		}
		if(sameCount !=0)
			counter++;
		System.out.println(counter);
		scan.close();
	}
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String in = new Scanner(System.in).nextLine();
        int hand = 0; int res = 0;
        char handType = '#';
        for(int i=0; i<in.length(); i++) {
            char c = in.charAt(i);
            if (handType == '#')
                handType = c;
            if (c == handType) {
                hand++;
            } else {
                res++;
                hand = 1;
                handType = c;
            }
            if (hand == 5) {
                res++;
                hand = 0;
            }
        }
        res += hand;
        System.out.println(res);
    }
}

import java.util.*;

public class A {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		char[] cs = (" " + s.next()).toCharArray();
		int c = 0, m = 1;
		for (int i = 1; i < cs.length; ++i) {
			if (cs[i - 1] != cs[i]) {
				++c;
				m = 1;
			} else if (++m > 5) {
				++c;
				m = 0;
			}
		}
		System.out.println(c);
	}
}

import java.util.Arrays;
import java.util.Scanner;

public class practice {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		int count = 1;
		int cons = 0;
		for(int i = 0; i<a.length()-1; i++) {
			if(cons >= 5) {
				count++;
				cons = 0;
			}
			if(a.charAt(i) == a.charAt(i+1))
				cons++;
			else {
				count++;
				cons = 0;
			}

		}
		System.out.println(count);
	}
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 1;

		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				c++;
			}
			if (h == 5) {
				h = 1;
				c++;
			}
		}
		if (w.charAt(w.length() - 2) != w.charAt(w.length() - 1)) { c++; }
		System.out.println(c);
	}
}

import java.util.Scanner;

public class Polycarpus{
	public static void main(String[]args){
		int count =0;
		int cnt = 0;

		Scanner reader = new Scanner(System.in);
		String input = reader.next();

		for(int ii =0; ii<input.length()-1;ii++){
			if(input.charAt(ii) == input.charAt(ii+1)){
				count++;
				if(count==5)
					cnt++;
			}
			else{
				cnt++;
				count =0;
			}
		}
		System.out.println(cnt);
	}
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 0;
		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				c++;
			}
			if (h == 5) {
				h = 0;
				c++;
			}
		}
		if (h != 0) { c++; }
		System.out.println(c);
	}
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		if (w.charAt(w.length() - 1) == 'C') {
			w += "P";
		} else {
			w += "C";
		}

		int c = 0;
		int h = 0;
		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				c++;
			}
			if (h == 5) {
				h = 0;
				c++;
			}
		}
		System.out.println(c);
	}
}

import java.util.*;
import java.io.*;
import java.*;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;

public class ragac1 {
	public static void main(String[] args) throws IOException {
		    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		    String str = "";
		        str = in.readLine();
		        int ans = 0;
		        int c=1;
		        int k = 0;
		        for (int i=1; i<str.length(); i++){
		        	if (str.charAt(i)==str.charAt(i-1)){
		        		c++;
		        		if ((c==5)&&(str.charAt(i+1)!= str.charAt(i))){
		        			k=i+1;
		        			ans++;
		        			c=1;
		        		} else if ((c==5)&&(str.charAt(i+1)== str.charAt(i))){
		        			ans++;
		        			c=1;
		        		}

		        	}else {
		        		if (k!=i){
		        			ans++;
		        		}

		        	}
		        }

		        System.out.print(ans+1);
		return;

	}
	}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;

public class A098 {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer token;
		ArrayList<Boolean> carry = new ArrayList<Boolean>();
		String line = in.nextLine();
		int count = 0;
		for (int x = 0; x < line.length(); x++) {
			boolean b = line.charAt(x) == 'C';
			boolean c = (carry.contains(!b));
			if (c || carry.size() >= 5) {
				carry.clear();
				count++;
			}
			carry.add(b);

		}
		System.out.println(count);
	}
}

//137/A

import java.util.Scanner;
public class Main {
    public static void main(String[]args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int count = 0;
        int c = 1;
        boolean b = false;
        for (int i = 1 ; i < s.length(); i++) {
            if (s.charAt(i-1) == 'C') b = true;
            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'C')) {
                c++;
                continue;
            }

            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'P')) {
                if (c % 5 == 0) {
                    count += 2*(c/5);
                } else {
                    count += 2*((c/5)+1);
                }
                c = 1;
            }// end of if-condition
        }// end of the for loop (i = 0)
        if (c > 1) {
            if (c % 5 == 0) {
                count += (c/5);
            } else {
                count += ((c/5)+1);
            }
        } else {
            if (s.charAt(s.length()-1) == 'C') count++;
        }
        if (b) {
            System.out.println(count);
        } else {
            System.out.println(count+1);
        }
    }//end of main method
}//end of class

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A1 implements Runnable {

    private void solve() throws IOException {
        String s = nextToken();
        int cnt = 0;
        int curCnt = 0;
        int changes = 1;
        for (int i = 1; i < s.length(); i++) {
            if(s.charAt(i) != s.charAt(i - 1)) changes++;
        }
        int cC = 0, pC = 0;

        while (!s.replaceFirst("CCCCC", "").equals(s)){
            s = s.replaceFirst("CCCCC", "");
            cC++;
        }
        while (!s.replaceFirst("PPPPP", "").equals(s)){
            s = s.replaceFirst("PPPPP", "");
            cC++;
        }
        writer.println(changes + cC + pC);
    }
    public static void main(String[] args) {
        new A1().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

//633

public class B {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String s = sc.nextLine();
		int ans = 0;
		int c = 1;
		/*String ss = "";
		char f = s.charAt(0);
		for(int i = 1;i < s.length();i++){
			if(f == s.charAt(i))
				c++;
			else {
				ss += c+""+f;
				f = s.charAt(i);
				c = 1;
			}
		}
		ss += c+""+f;
		//pw.println(ss);
		String num = "";
		for(int i = 0;i < ss.length();i++){
			if(Character.isDigit(ss.charAt(i))){
				num += ss.charAt(i);
			}
			else {
				ans += Integer.parseInt(num) <= 5 ? 1: (Integer.parseInt(num)/5) + Integer.parseInt(num) % 5;
				num = "";
			}
		}*/

		for(int i = 1;i < s.length();i++){
			if(s.charAt(i) != s.charAt(i - 1)){
				ans += c <= 5? 1: (c/5) + (c%5);
				c = 1;
			}
			else
				c++;
			if(i == s.length() - 1)
				ans += c <= 5? 1: (c/5) + (c%5);
		}
		if(s.length() == 1)
			ans++;
		pw.println(ans);
		pw.close();
	}

	static class MyScanner {
		StringTokenizer st;
		BufferedReader br;

		public MyScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

//137/A

import java.util.Scanner;
public class Main {
    public static void main(String[]args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int count = 0;
        int c = 1;
        boolean b = false;
        for (int i = 1 ; i < s.length(); i++) {
            if (s.charAt(i-1) == 'C') b = true;
            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'C')) {
                c++;
                continue;
            }

            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'P')) {
                if (c % 5 == 0) {
                    count += 2*(c/5);
                } else {
                    count += 2*((c/5)+1);
                }
                c = 1;
            }// end of if-condition
        }// end of the for loop (i = 0)
        if (c > 1) {
            if (c % 5 == 0) {
                count += (c/5);
            } else {
                count += ((c/5)+1);
            }
        } else {
            if (s.charAt(s.length()-1) == 'C') count++;
        }
        if (s.charAt(s.length()-1) == 'C') b =true;
        if (b) {
            System.out.println(count);
        } else {
            System.out.println(count+1);
        }
    }//end of main method
}//end of class

import java.util.*;
import java.io.*;

public class c137 {
	static int f(String s, int n, char c, int ans) {
		if (s.isEmpty()) {
			if (n > 0) return ans + 1;
			else return ans;
		}
		if (n == 5) return f(s, 0, s.charAt(0), ans + 1);
		else {
			if (s.charAt(0) == c)
				return f(s.substring(1), n + 1, s.charAt(0), ans);
			else
				return f(s.substring(1), 1, s.charAt(0), ans + 1);
		}
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int ans = 0;
		ans = f(s, 1, s.charAt(0), ans);
		System.out.println(ans);
	}
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 1;

		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				h = 1;
				c++;
			}
			if (h == 5) {
				h = 1;
				c++;
			}
		}
		if (w.charAt(w.length() - 2) != w.charAt(w.length() - 1)) { c++; }
		if ((w.charAt(w.length() - 2) == w.charAt(w.length() - 1)) && (h > 1)) { c++; }
		System.out.println(c);
	}
}

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;

public class ClosetPC {

	public static void main(String[] args) throws IOException {
		BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
		char[] item = lector.readLine().toCharArray();
		int cont = 0;
		boolean iP = true;
		int carry =0;
		for(int i=0; i<item.length; i++){
			if(carry == 5) {
				carry=1;
				iP = item[i] == 'P'?true:false;
				cont++;
			}
			else if(iP && item[i] == 'P') carry++;
			else if(!iP && item[i] == 'C') carry++;
			else {
				cont++;
				carry=1;
				iP = !iP;
			}
		}
		System.out.println(cont);
		lector.close();
	}
}

import java.io.*;
public class Lucky_numbers {

    public static void main(String[] args) throws IOException{
       BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
     String s= br.readLine();
     String [] str= s.split("");
     int count=0, sum=1;
     for (int i=1; i<str.length-1;i++)
     {
        StringBuffer b= new StringBuffer(str[i]);

         if(str[i+1].contentEquals(b) )
         {sum++; System.out.println(sum);
         if (sum>=5)
         {
             count++;
             sum=0;
         }
         }
        else

         { sum=1 ;  count++;}

     } if (sum >0) count++ ; System.out.println(count);
}}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A1 implements Runnable {

    private void solve() throws IOException {
        String s = nextToken();
        int cnt = 0;
        int curCnt = 0;

        char[] a = s.toCharArray();

        for (int i = 0; i < a.length; i++) {
            if(i == 0){
                curCnt = 1;
            }else {
                if(a[i] != a[i - 1]) {
                    curCnt = 1;
                    cnt++;
                }else if(curCnt == 5){
                    curCnt = 0;
                    cnt++;
                } else {
                    curCnt++;
                }
            }
            //writer.println("char[i]:" + a[i] + ", i:" + i + ", curCnt:" + curCnt + ", cnt:" + cnt);
        }

        writer.println(cnt + 1);

    }
    public static void main(String[] args) {
        new A1().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.util.Scanner;

public class PostCards
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        char arr[];
        int i = 0;
        String input = s.next();
        arr = input.toCharArray();
        int curr = 0;
        int sum = 0;
        i = input.length();
        for(int n=0;n<i-1;n++)
        {
            if(arr[n] != arr[n+1])
            {
                curr = 0;
                sum++;
            }
            else if(arr[n] == arr[n+1] && curr < 5)
            {
                curr++;
            }
            else
            {
                sum++;
                curr = 0;
            }
        }
        System.out.println(sum+1);
    }
}

import java.io.*;
public class Foto{
    public static void main(String[] argv) throws IOException
    {
   int kol=0;
    byte[] Message= new byte[100];
    int m_long=System.in.read(Message);
    int C_long=0;
        if(m_long>0){
        boolean C=false;
        if((char)Message[0]=='C')
        C=true;
        for(int i=0;i<m_long;i++){
        if((char)Message[i]=='C')
        {
            if(C){
            C_long++;
             }else{
            C=true;
//            C_long++;
            //kol++;
            while(C_long>0)
            {
            C_long-=5;
            kol++;
            }
            C_long=1;
            }
        }else{
        if(!C){
            C_long++;
            }else{
            C=false;
//            C_long++;
            //kol++;
            while(C_long>0)
            {
            C_long-=5;
            kol++;
            }
            C_long=1;
            }
        }
        }

            while(C_long>=5)
            {
            C_long-=5;
            kol++;
            }
            if(C_long>0)
            kol++;
        System.out.println(kol);
        }
    }
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 0;
		if (w.charAt(0) == w.charAt(1)) { h = 1; }
		for (int i = 1; i < w.length(); i++) {
			if (w.charAt(i - 1) == w.charAt(i)) {
				h++;
			} else {
				c++;
			}
			if (h == 5) {
				h = 0;
				c++;
			}
		}
		System.out.println(c);
	}
}

import java.util.Scanner;

public class Polycarpus{
	public static void main(String[]args){
		int count =0;
		int cnt = 0;

		Scanner reader = new Scanner(System.in);
		String input = reader.next();

		for(int ii =0; ii<input.length()-1;ii++){
			if(input.charAt(ii) == input.charAt(ii+1)){
				count++;
				if(count==5)
					cnt++;
			}
			else{
				cnt++;
				count =0;
			}
		}
		System.out.println(cnt);
	}
}

import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)throws IOException {
        Scanner scanner = new Scanner(System.in);
        StringBuilder line = new StringBuilder(scanner.next());
        int minimum = 0;
        int counter = 0;
        if(line.charAt(line.length()-1) != line.charAt(line.length()-2)){
            minimum++;
        }
        char c = line.charAt(0);
        while(line.length() != 0){
            char currntChar = line.charAt(0);
            if(c == currntChar){
                    counter++;
            } else {
                    c = currntChar;
                    counter = 1;
                    minimum++;
            }
            if(counter == 5){
                minimum++;
                counter = 0;
            }
            line.deleteCharAt(0);
        }
        System.out.println(minimum);
    }
}

import java.io.*;
public class Lucky_numbers {

    public static void main(String[] args) throws IOException{
       BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
     String s= br.readLine();
     String [] str= s.split("");
     int count=0, sum=0;
     for (int i=1; i<str.length-1;i++)
     {
        StringBuffer b= new StringBuffer(str[i]);

         if(str[i+1].contentEquals(b))
         {sum++;
         if (sum>=5)
         {
             count++;
             sum=0;
         }
         }
        else if (str[i]!= str[i+1])
         {count++;}

     } if (sum < 5) count++ ; System.out.println(count);
}}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

//633

public class B {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String s = sc.nextLine();
		int ans = 0;
		int c = 1;
		String ss = "";
		char f = s.charAt(0);
		for(int i = 1;i < s.length();i++){
			if(f == s.charAt(i))
				c++;
			else {
				ss += c+""+f;
				f = s.charAt(i);
				c = 1;
			}
		}
		ss += c+""+f;
		//pw.println(ss);
		String num = "";
		for(int i = 0;i < ss.length();i++){
			if(Character.isDigit(ss.charAt(i))){
				num += ss.charAt(i);
			}
			else {
				ans += Integer.parseInt(num) <= 5 ? 1: (Integer.parseInt(num)/5) + Integer.parseInt(num) % 5;
				num = "";
			}
		}
		pw.println(ans);
		pw.close();
	}

	static class MyScanner {
		StringTokenizer st;
		BufferedReader br;

		public MyScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 0;
		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				c++;
			}
			if (h == 5) {
				h = 0;
				c++;
			}
		}
		if (w.charAt(w.length() - 2) != w.charAt(w.length() - 1)) { c++; }
		System.out.println(c);
	}
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String in = new Scanner(System.in).nextLine();
        int hand = 0; int res = 0;
        char handType = '#';
        for(int i=0; i<in.length(); i++) {
            char c = in.charAt(i);
            if (handType == '#')
                handType = c;
            if (c == handType) {
                hand++;
            } else {
                res++;
                hand = 1;
                handType = c;
            }
            if (hand == 5) {
                res++;
                hand = 0;
            }
        }
        res += hand;
        System.out.println(res);
    }
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 1;

		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				c++;
			}
			if (h == 5) {
				h = 1;
				c++;
			}
		}
		if (w.charAt(w.length() - 2) != w.charAt(w.length() - 1)) { c++; }
		System.out.println(c);
	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A implements Runnable {

	private void Solution() throws IOException {
		String s = nextToken();

		int count = 1, ans = 0;

		for (int i = 1; i < s.length(); i++) {
			count++;

			if (s.charAt(i) != s.charAt(i - 1)) {
				count = 1;
				ans++;
			}

			if (count == 5) {
				count = 0;
				ans++;
			}

			if (count != 0 && i == s.length() - 1)
				ans++;
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new A().run();
	}

	BufferedReader in;
	StringTokenizer tokenizer;
	PrintWriter out;

	public void run() {
		try {
			String name = "";
			name = "system";
			if (name.equals("system")) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(new OutputStreamWriter(System.out));
			} else if (name.equals("")) {
				in = new BufferedReader(new FileReader(new File("input.txt")));
				out = new PrintWriter(new File("output.txt"));
			} else {
				in = new BufferedReader(new FileReader(new File(name + ".in")));
				out = new PrintWriter(new File(name + ".out"));
			}
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}
}

import java.util.Scanner;

public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 0;
		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				c++;
			}
			if (h == 5) {
				h = 0;
				c++;
			}
		}
		if (h == 0) { c++; }
		System.out.println(c);
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class MainB {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int ans=0;
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(i)=='C')
			{
				int c=0;
				int j=i;
				for( j=i;j<s.length();j++)
				{
					if(s.charAt(j)=='C')c++;
					else
						break;
				}
				if(c%5==0)
					ans+=(c/5);
				else
				{
					ans+=(c/5);
					c-=((c/5)*5);ans+=c;
				}
				i=j;
			}
			else if(s.charAt(i)=='P')
			{
				int c=0;
				int j=i;
				for(j=i;j<s.length();j++)
				{
					if(s.charAt(j)=='P')c++;
					else
						break;
				}
				if(c%5==0)
					ans+=(c/5);
				else
				{
					ans+=(c/5);
					c-=((c/5)*5);ans+=c;
				}
				i=j;
			}
		}
		System.out.println(ans);
		//System.out.println(n-ans);
       // 	int n=sc.nextInt();
      /*  LL ll=new LL();
        ll.head1=new NodeL(1);
        ll.head1.next=new NodeL(2);
        ll.head1.next.next=new NodeL(3);
        ll.head1.next.next.next=new NodeL(2);

        ll.head1.next.next.next.next=new NodeL(1);
        ll.isPal(ll.head1);
        //ll.Swap(ll.head,1,3);
        //ll.Reverse(ll.head1);
       //System.out.println(ll.head1.data);
        // System.out.println("---");
     //   ll.Middle(ll.head);
        //ll.NthLast(ll.head,2);

		/*Binary tree=new Binary();
		tree.root=new Node(6);
		tree.root.left=new Node(3);
		tree.root.right=new Node(5);
		tree.root.left.left=new Node(2);
		tree.root.left.right=new Node(5);
		tree.root.left.right.left=new Node(7);
		tree.root.left.right.right=new Node(4);
		tree.root.right.right=new Node(4);

	tree.PrintInOrder(tree.root);
	int tot=tree.countNodes(tree.root);
	boolean bool=tree.IsComplete(tree.root,0, tot);
	System.out.println(bool);
    //tree.leftview(tree.root, 1);
    tree.leftleaf(tree.root,1,false);
    tree.SumAllMax(tree.root,0);
    System.out.println(tree.ans);*/
	}

}

import java.io.PrintWriter;
import java.util.Scanner;

public class Main implements Runnable {

	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	String input;
	int output;
	int counter=0;
	Character c;

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	private void read() {
		input = in.nextLine();
	}

	private void solve() {

		for (int i = 0; i < input.length()-1; i++) {
//			out.print(input.charAt(i));
			c=input.charAt(i);
			if (c.equals(input.charAt(i + 1))) {
				counter++;
				if (counter == 5) {
					counter = 0;
					output++;
				}
			}

			else if(!c.equals(input.charAt(i + 1))) {
				counter=1;
				output++;
			}

		}
		if(counter!=0)
			output++;

	}

	private void write() {
		out.println(output);
	}

	@Override
	public void run() {
		read();
		solve();
		write();
		in.close();
		out.flush();
		out.close();
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	public static void main (String[]args)
	{
		Scanner read = new Scanner (new BufferedInputStream (System.in));
		String n = read.next();
		int count=0;
		int temp=0;
		String x="";
		for (int i=0;i<n.length();i++)
		{
			if (temp==5 || !x.equals(n.substring(i,i+1)))
			{
				count++;
				x="";
				temp=0;
			}
			if (temp==0&&i!=n.length()-1)
			{
				x=n.substring(i, i+1);
				temp++;
				System.out.println(x);
			}
			else if (temp<5 && x.equals(n.substring(i, i+1)))
			{
				temp++;
			}

			//System.out.println(i+" "+temp+);
		}
		System.out.println(count);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class A {

    public static void main( final String[] args ) throws IOException {
        final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        final String items = br.readLine();
        int cnt = 1;
        int group = 1;
        char type = items.charAt( 0 );
        for ( int i = 1; i < items.length(); ++i ) {
            final char c = items.charAt( i );
            if ( c == type ) {
                if ( group < 5 ) {
                    ++group;
                } else {
                    ++cnt;
                    group = 0;
                }
            } else {
                ++cnt;
                group = 1;
                type = c;
            }
        }
        System.out.println( cnt );
    }
}

//137/A

import java.util.Scanner;
public class Main {
    public static void main(String[]args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();

        int count = 1;
        int c = 0;

        for (int i = 0 ; i < s.length()-1; i++) {
            if (s.charAt(i) != s.charAt(i+1)) {
                count++;
            }
            else {
                c++;
            }
            if (c >= 5) {
                count++;
                c = 0;
            }
        }
        System.out.println(count);

    }//end of main method
}//end of class

import java.io.*;
import java.lang.*;
import java.util.*;
import java.util.ArrayList;
import java.text.DecimalFormat;

public class Main {
    public static void cout(String s)
    {
        System.out.print(s);

    }
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s=in.nextLine();
            int i;
            int ans,c;
            ans=0;
            c=1;
            for(i=1;i<s.length();i++)
            {
                if(s.charAt(i)==s.charAt(i-1))
                {
                    c++;
                    if(c==5)
                    {
                        ans++;
                        c=0;
                    }
                }
                else
                {
                    ans++;
                    c=1;
                }

            }
            System.out.println(ans);

        }
    }

}

import java.util.Scanner;
public class Main4{
	public static void main (String [] args){
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		int times = 0 , count = 1;
		for (int i = 1 ; i < s.length() ; i++){
			if (s.charAt(i-1) != s.charAt(i)){
				times++;
				count = 1;
				if (i == s.length()-1)
					times++;
			}
			else{
				count++;
				if (count == 5){
					times++;
					count = 1;
					i++;
				}
				if (i == s.length()-1)
					times++;
			}
		}
		System.out.println(times);
	}
}

import java.util.*;

public class Main {

        public static void main(String[] args){
        Scanner input = new Scanner(System.in);

             String s = input.next();
             int count = 0;
             int x = 1;
             if(s.length()==1){
                 System.out.println(1);
             }
             else{
             for (int i = 1; i < s.length(); i++) {

                if(s.charAt(i)== s.charAt(i-1)){
                    x++;
                 if(x==5){
                    count++;
                    x=0;}
                }
                else
                {
                        count++;
                        x=1;
                }

                 if((i==s.length()-1 && x==1) || count==0 && i==s.length()-1 )
                     count++;

            }
             System.out.println(count);
            }
        }

}

import java.util.Scanner;
public class Postcard_And_Photos
{
	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		String str=scan.nextLine();
		int len=str.length();
		int i=0,c1=0,c2=1;
		if(len==1)
		{
			System.out.println(1);
			return;
		}
		for(i=1;i<len;i++)
		{
			if(i==len-1)
			{
				if(str.charAt(i)==str.charAt(i-1))
					c1++;
				else
					c1+=2;
			}
			else
			{
				if(str.charAt(i)==str.charAt(i-1))
					c2++;
				else
				{
					c1++;
					//System.out.println("Vega "+c1);
					c2=1;
				}
				if(c2==5)
				{
					c1++;
					c2=0;
				}
			}
		}
		System.out.println(c1);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A1 implements Runnable {

    private void solve() throws IOException {
        String s = nextToken();
        int cnt = 0;
        int onHand = 0;
        for (int i = 0; i < s.length(); i++) {
            if(i == 0) onHand = 1; else
            if(s.charAt(i) != s.charAt(i - 1)){
                cnt++;
                onHand = 1;
            } else if(onHand == 5){
                onHand = 1;
                cnt++;
            } else if(i == s.length() - 1) cnt++;
            else onHand++;
        }
        writer.print(cnt);
    }
    public static void main(String[] args) {
        new A1().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        char str[] = in.nextLine().toCharArray();
        char curr = str[0];
        int count = 0;
        int occurence = 0;
        for (int i = 0; i < str.length; i++) {
            if (str[i] == curr) {
                ++occurence;
                if (occurence == 5) {
                    ++count;
                    occurence = 0;
                }
            } else {
                ++count;
                occurence = 1;
                curr = str[i];
            }
        }
        if (occurence > 0)
            ++count;
        System.out.println(count);
    }
}

import java.util.*;

public class Main {

        public static void main(String[] args){
        Scanner input = new Scanner(System.in);

             String s = input.next();
             int count = 0;
             int x = 1;
             for (int i = 1; i < s.length(); i++) {

                if(s.charAt(i)== s.charAt(i-1)){
                    x++;}
                else
                {
                        count++;
                        x=1;
                }
                 if(x==5){
                    count++;
                    x=0;}
                 if(i==s.length()-1 && x==1)
                     count++;
            }
             System.out.println(count);
            }

}

import java.util.Scanner;

public class A_98 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        String a = s.next();

        int begin = 1;
        char ss = a.charAt(begin-1);
        int count = 1;
        int result = 0;

        while (begin < a.length()) {

            for (int i = begin; i < a.length(); i++) {

                if(a.charAt(i) == ss)
                {
                    count++;
                }
                else {
                    begin = i+1;
                    ss = a.charAt(i);
                    break;
                }

                if(i == a.length()-1)
                {
                    begin = i+1;
                    break;}
            }

            if((count == 1 || count == 2))
                if(result==0)
                    result +=2;
                else
                result +=1;

            else
                result += 2;

            count =1 ;

            //System.out.println("reach");
        }

        System.out.println(result);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Solution  {
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        String s = reader.readLine();
        char[] charArr = s.toCharArray();
        int k = 1;
        int answer = 0;

        for (int i = 0; i < charArr.length - 1; i++) {
            if(charArr[i] == charArr[i + 1]) k++;
            else {
                answer += k / 5;
                if(k % 5 != 0) answer++;
                //System.out.println(answer);
                k = 1;
            }
            if(i == charArr.length - 2) {
                if(k == 1) answer++;
                else {
                    answer += k / 5;
                    if(k % 5 != 0) answer++;
                }
            }
        }

        System.out.println(answer);
    }
}

import java.io.*;
public class Foto{
    public static void main(String[] argv) throws IOException
    {
   int kol=0;
    byte[] Message= new byte[100];
    int m_long=System.in.read(Message);
    int C_long=0;
        if(m_long>0){
        boolean C=false;
        if(((char)Message[0]=='C')||((char)Message[0]=='c'))
        C=true;
        for(int i=0;i<m_long;i++){
        if(((char)Message[i]=='C')||((char)Message[i]=='c'))
        {
            if(C){
            C_long++;
             }else{
            C=true;
            while(C_long>0)
            {
            C_long-=5;
            kol++;
            }
            C_long=1;
            }
        }else{
        if(!C){
            C_long++;
            }else{
            C=false;
            while(C_long>0)
            {
            C_long-=5;
            kol++;
            }
            C_long=1;
            }
        }
        }

            while(C_long>=5)
            {
            C_long-=5;
            kol++;
            }
            if(C_long>0)
            kol++;
        System.out.print(kol);
        }
    }
}

import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)throws IOException {
        Scanner scanner = new Scanner(System.in);
        StringBuilder line = new StringBuilder(scanner.next());
        int minimum = 0;
        int counter = 0;
        if(line.charAt(line.length()-1) != line.charAt(line.length()-2)){
            minimum++;
        }
        char c = line.charAt(0);
        while(line.length() != 0){
            char currntChar = line.charAt(0);
            if(c == currntChar){
                    counter++;
            } else {
                    c = currntChar;
                    counter = 1;
                    minimum++;
            }
            if(counter == 5){
                minimum++;
                counter = 0;
            }
            line.deleteCharAt(0);
        }
        System.out.println(minimum);
    }
}

import java.util.Arrays;
import java.util.Scanner;

public class practice {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		int count = 1;
		int cons = 0;
		for(int i = 0; i<a.length()-1; i++) {
			if(cons >= 5) {
				count++;
				cons = 0;
			}
			if(a.charAt(i) == a.charAt(i+1))
				cons++;
			else {
				count++;
				cons = 0;
			}

		}
		System.out.println(count);
	}
}

import java.io.*;
import java.util.*;
public class div98A
{
	public static void main(String args[])throws IOException
	{
		boolean oj=System.getProperty("ONLINE_JUDGE")!=null;
		BufferedReader in=oj?(new BufferedReader(new InputStreamReader(System.in))):(new BufferedReader(new FileReader("input.txt")));
		PrintWriter ob=oj?new PrintWriter(System.out):new PrintWriter("output.txt");
		char a[]=in.readLine().toCharArray();
		int l=a.length;
		int flag=0,cnt=0,ans=0;
		char prev=' ';
		for(int i=0;i<l;i++){
		//	System.out.println(a[i]+"  "+cnt+" "+ans);
			if(flag==1 && prev==a[i] && cnt+1<5)
				{cnt+=1;continue;}
			if(flag==0 && i<=l-2 && a[i]==a[i+1])
				{cnt=2;prev=a[i];flag=1;continue;}
			else
			{
				ans+=1;
				cnt=0;
				flag=0;
			}
		}
		ob.println(ans);
		ob.flush();
		ob.close();
	}
}

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;

public class ClosetPC {

	public static void main(String[] args) throws IOException {
		BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
		char[] item = lector.readLine().toCharArray();
		int cont = 0;
		boolean iP = true;
		int carry =0;
		for(int i=0; i<item.length; i++){
			if(carry == 5) {
				carry=1;
				iP = item[i] == 'P'?true:false;
				cont++;
			}
			else if(iP && item[i] == 'P') carry++;
			else if(!iP && item[i] == 'C') carry++;
			else {
				cont++;
				carry=1;
				iP = !iP;
			}
		}
		if(carry>1)cont++;
		System.out.println(cont);
		lector.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PostcardsAndPhotos_137A {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		char pre = input.charAt(0);
		int carry = 1;
		int count = 0;
		boolean flag = false;
		for (int i = 1; i < input.length(); i++) {
			if(input.charAt(i) == pre){
				carry++;
				if(carry == 5){
					carry = 0;
					count++;
				}
			}else{
				flag = true;
				count++;
				carry = 0;
			}
			pre = input.charAt(i);
		}
		if(flag)
			System.out.println(count+1);
		else
			System.out.println(count);

	}

}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author codeKNIGHT
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
     String s=in.next();
        int c=0,t=0;
        char ch='A';
        for(int i=0;i<s.length();i++)
        {
            if(t==5)
            {
                c++;
                t=0;
            }
            if(s.charAt(i)==ch)
                t++;
            else
            {
                ch=s.charAt(i);
                c++;
                t=1;
            }

        }
        out.println(c);

	}
}

import java.io.PrintWriter;
import java.util.Scanner;

public class Main implements Runnable {

	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	String input;
	int output;
	int counter=0;
	Character c;

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	private void read() {
		input = in.nextLine();
	}

	private void solve() {

		if(input.length()==1) {
			output=1;
			return;
		}

		for (int i = 0; i < input.length()-1; i++) {
//			out.print(input.charAt(i));
			c=input.charAt(i);
			if (c.equals(input.charAt(i + 1))) {
				counter++;
				if (counter == 5) {
					counter = 0;
					output++;
					i++;
				}
			}

			else if(!c.equals(input.charAt(i + 1))) {
				counter=1;
				output++;
			}

		}
		if(counter!=0)
			output++;

	}

	private void write() {
		out.println(output);
	}

	@Override
	public void run() {
		read();
		solve();
		write();
		in.close();
		out.flush();
		out.close();
	}
}

import java.util.*;

public class A {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		char[] cs = (" " + s.next()).toCharArray();
		int c = 0, m = 1;
		for (int i = 1; i < cs.length; ++i) {
			if (cs[i - 1] != cs[i]) {
				++c;
				m = 1;
			} else if (++m > 5) {
				++c;
				m = 0;
			}
		}
		System.out.println(c);
	}
}

import java.io.*;
import java.util.*;
public class div98A
{
	public static void main(String args[])throws IOException
	{
		boolean oj=System.getProperty("ONLINE_JUDGE")!=null;
		BufferedReader in=oj?(new BufferedReader(new InputStreamReader(System.in))):(new BufferedReader(new FileReader("input.txt")));
		PrintWriter ob=oj?new PrintWriter(System.out):new PrintWriter("output.txt");
		char a[]=in.readLine().toCharArray();
		int l=a.length;
		int flag=0,cnt=0,ans=0;
		char prev=' ';
		for(int i=0;i<l;i++){
		//	System.out.println(a[i]+"  "+cnt+" "+ans);
			if(flag==1 && i==l-1 && prev==a[i] && cnt+1<5)
			{
				ans+=1;
				break;
			}
			if(flag==1 && prev==a[i] && cnt+1<5)
				{cnt+=1;continue;}
			if(flag==0 && i<=l-2 && a[i]==a[i+1])
				{cnt=2;prev=a[i];flag=1;continue;}
			else
			{
				ans+=1;
				cnt=0;
				flag=0;
			}
		}
		ob.println(ans);
		ob.flush();
		ob.close();
	}
}

//137/A

import java.util.Scanner;
public class Main {
    public static void main(String[]args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int count = 0;
        int c = 0;
        for (int i = 1 ; i < s.length(); i++) {
            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'C')) {
                c++;
                continue;
            }

            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'P')) {
                if ((c+1) % 5 == 0) {
                    count += 2*((c+1)/5);
                } else {
                    count += 2*(((c+1)/5)+1);
                }
                c = 0;
            }// end of if-condition
        }// end of the for loop (i = 0)
        if ((c+1) > 1) {
            if ((c+1) % 5 == 0) {
                count += ((c+1)/5);
            } else {
                count += (((c+1)/5)+1);
            }
        } else {
            if (s.charAt(s.length()-1) == 'C') count++;
        }
        System.out.println(count);
    }//end of main method
}//end of class

import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class  test  {

public  static void main(String[] args) {
   Scanner sc =new Scanner(System.in);

   while(sc.hasNext()){
  String s=sc.next();
	   //int n=ni(sc),
  int r=1;

	  //  Collections.sort(lis);

	   char c=s.charAt(0);
	   for(int i=1,h=1;i<s.length();i++){

		   if(s.charAt(i)==c){
			   if(h==0)r++;
			   h++;
			   if(h==5){r+= (r!=1)? 1:0;
			   h=1;}
		   }

		   else {
			   h=1;
			   r++;
			   c=s.charAt(i);
		   }

	   }

	   System.out.println(r);
	   }

  // System.out.println(r);
   }

    static int ni(Scanner in){
	return in.nextInt();
 }

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

import java.util.*;
public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scan = new Scanner(System.in);
        char[] l1 = scan.next().toCharArray();
        int fin = 0;
        char type = l1[0];
        int cur =0;
        for (char e: l1){
            if (e==type){
                cur++;
                if (cur==5){
                    cur=0;
                    fin++;
                }
            }
            else {
                cur=1;
                type=e;
                fin++;
            }
        }
        if (cur!=0){
            cur=0;
            fin++;
        }
        System.out.println(fin);
    }

}

import java.util.Scanner;

public class PostCards
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        char arr[];
        int i = 0;
        String input = s.next();
        arr = input.toCharArray();
        int curr = 0;
        int sum = 0;
        i = input.length();
        for(int n=0;n<i-1;n++)
        {
            if(arr[n] != arr[n+1])
            {
                curr = 0;
                sum++;
            }
            else if(arr[n] == arr[n+1] && curr < 5)
            {
                curr++;
            }
            else
            {
                sum++;
                curr = 0;
            }
        }
        System.out.println(sum+1);
    }
}

/*
 Author: Togrul Gasimov
 Mail: ttogrul30@gmail.com
 */

import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;
import java.util.Scanner;
import java.util.Vector;
import java.util.Arrays;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.List;
import java.util.Stack;

public class Main {

// Function begin

//Function end
static Scanner scan = new Scanner(System.in);
//variables begin
//static double PI=3.1415926535897932384626433832795,E=1e-9;
static String s;
//variables end

static void read(){

   s=scan.next();

}
static void solve(){
	int l=s.length();

	int t=1,ans=0;

	for(int i=0;i<=l-2;i++){
		if(s.charAt(i)==s.charAt(i+1)){
			t++;
			if(t==5){ans++; t=1;}
		}else{
			ans++;
		}
		if(i==l-2 && t==1)ans+=1;
	}

	System.out.println(ans +" " + t);

}

public static void main(String[] args) {
  read();
  solve();
}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	public static void main (String[]args)
	{
		Scanner read = new Scanner (new BufferedInputStream (System.in));
		String n = read.next();
		int count=0;
		int temp=0;
		String x="";
		for (int i=0;i<n.length();i++)
		{
			if (temp==5 || !x.equals(n.substring(i,i+1)))
			{
				count++;
				x="";
				temp=0;
			}
			if (temp==0&&i!=n.length()-1)
			{
				x=n.substring(i, i+1);
				temp++;
				System.out.println(x);
			}
			else if (temp<5 && x.equals(n.substring(i, i+1)))
			{
				temp++;
			}

			//System.out.println(i+" "+temp+);
		}
		System.out.println(count);
	}
}

import java.util.Scanner;
public class PostcardAndPhotos{
    public static void main(String [] args){
        Scanner input = new Scanner(System.in);
        String masuk = input.nextLine();
        int count = 0;
        int itung = 1;
        char temp = masuk.charAt(0);
        if(masuk.length()<2) System.out.println(1);
        else{
            for(int i = 1; i< masuk.length();i++){
// System.out.println(i);
                char a = masuk.charAt(i);
// System.out.println(temp);
// System.out.println(a);
                if(temp == a)itung++;
// System.out.println("lanjut");
                else{
                    itung =0;
                    count++;
                    i--;
// System.out.println(" pulang");
                }
                if(itung == 6){
                    itung = 0;
                    count++;
// System.out.println(" lebih");
                }
                temp = a;
            }
            System.out.println(count+1);

        }
    }
}

import java.util.Scanner;

public class PostCards
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        char arr[];
        int i = 0;
        String input = s.next();
        arr = input.toCharArray();
        int curr = 0;
        int sum = 0;
        i = input.length();
        for(int n=0;n<i-1;n++)
        {

            System.out.println(curr);
            if(arr[n] != arr[n+1])
            {
                curr = 0;
                sum++;
            }
            else if(arr[n] == arr[n+1] && curr < 4)
            {
                curr++;
            }
            else
            {
                sum++;
                curr = 0;
            }
        }
        System.out.println(sum+1);
    }
}

import java.util.*;
import java.io.*;

public class A{ //��� ������ ������ ���� Main
  public static void main(String[] argv) throws IOException{
 Scanner in = new Scanner(System.in); int k=0,ans=0;
 String St = in.next(); St+='K';
 for (int i=0;i<St.length();i++)
	 if (k==5 || (i>0 && St.charAt(i)!=St.charAt(i-1))) {ans++;k=0;} else k++;

	 System.out.println(ans);

  }

}

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

    private void solve() throws IOException {
        String a = nextToken();
        char lastknown = ' ';
        int count = 0, result = 0;
        for (int x = 0; x < a.length(); x++) {
            if (a.charAt(x) == 'C' && lastknown == 'C') {
                if (count < 5) {
                    count++;
                } else {
                    count = 0;
                    result++;
                }
            } else if (a.charAt(x) == 'C' && lastknown == 'P') {
                count = 0;
                result++;
            } else if (a.charAt(x) == 'P' && lastknown == 'P') {
                if (count < 5) {
                    count++;
                } else {
                    count = 0;
                    result++;
                }
            } else {
                count = 0;
                result++;
            }
            lastknown = a.charAt(x);
        }
        out.println(result);
    }

    public static void main(String[] args) {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            new Main().solve();
            out.close();
        } catch (Throwable e) {
            System.out.println(e);
            System.exit(239);
        }
    }
    static BufferedReader br;
    static StringTokenizer st;
    static PrintWriter out;

    static String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    static int[] nextIntArray(int n) throws IOException {
        int[] temp = new int[n];
        for (int x = 0; x < n; x++) {
            temp[x] = nextInt();
        }
        return temp;
    }

    static long[] nextLongArray(int n) throws IOException {
        long[] temp = new long[n];
        for (int x = 0; x < n; x++) {
            temp[x] = nextLong();
        }
        return temp;
    }

    static String[] nextArray(int n) throws IOException {
        String[] temp = new String[n];
        for (int x = 0; x < n; x++) {
            temp[x] = nextToken();
        }
        return temp;
    }
}

import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)throws IOException {
        Scanner scanner = new Scanner(System.in);
        StringBuilder line = new StringBuilder(scanner.next());
        int minimum = 0;
        int counter = 0;
        char c = line.charAt(0);
        while(line.length() != 0){
            char currntChar = line.charAt(0);
            if(c == currntChar){
                    counter++;
            } else {
                    c = currntChar;
                    counter = 1;
                    minimum++;
            }
            if(counter == 5){
                minimum++;
                counter = 0;
            }
            line.deleteCharAt(0);
        }
        if(counter>0){
            minimum++;
        }
        System.out.println(minimum);
    }
}

import java.util.Scanner;
public class Main4{
	public static void main (String [] args){
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		int times = 0 , count = 1;
		for (int i = 1 ; i < s.length() ; i++){
			if (s.charAt(i-1) != s.charAt(i)){
				times++;
				count = 1;
				if (i == s.length()-1)
					times++;
			}
			else{
				count++;
				if (count == 5){
					times++;
					count = 1;
					i++;
				}
				if (i == s.length()-1)
					times++;
			}
		}
		System.out.println(times);
	}
}

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;

public class ClosetPC {

	public static void main(String[] args) throws IOException {
		BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
		char[] item = lector.readLine().toCharArray();
		int cont = 0;
		boolean iP = true;
		int carry =0;
		for(int i=0; i<item.length; i++){
			if(carry == 5) {
				carry=1;
				iP = item[i] == 'P'?true:false;
				cont++;
			}
			else if(iP && item[i] == 'P') carry++;
			else if(!iP && item[i] == 'C') carry++;
			else {
				cont++;
				carry=1;
				iP = !iP;
			}
		}
		if(carry>1 && carry<5)cont++;
		System.out.println(cont);
		lector.close();
	}
}

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.io.*;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		// Scanner read = new Scanner(new FileInputStream(new
		// File("input.txt")));
		// PrintWriter out = new PrintWriter(new File("output.txt"));
		Scanner read = new Scanner(System.in);
		String x = read.nextLine();
		char a = x.charAt(0);
		int min = 0, count = 1;
		if (x.length() == 1)
			System.out.println("1");
		else {
			for (int i = 1; i < x.length(); i++) {
				if (x.charAt(i) == a) {
					count++;
					if (count == 5) {
						min++;
						count = 0;
					}
				} else {
					min++;
					count = 1;
					a = x.charAt(i);
				}
			}
			if (x.charAt(x.length() - 2) == a && count < 5 && count > 0)
				min++;
			else if (x.charAt(x.length() - 2) != a)
				min++;

			System.out.println(min);
		}
	}
}

import java.util.Scanner;

public class A_98 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        String a = s.next();

        int begin = 1;
        char ss = a.charAt(begin-1);
        int count = 1;
        int result = 0;

        while (begin < a.length()) {

            for (int i = begin; i < a.length(); i++) {

                if(a.charAt(i) == ss)
                {
                    count++;
                }
                else {
                    begin = i+1;
                    ss = a.charAt(i);
                    break;
                }

                if(i == a.length()-1)
                {
                    begin = i+1;
                    break;}
            }

            if((count == 1 || count == 2))
                if(result==0)
                    result +=2;
                else
                result +=1;

            else
                result += 2;

            count =1 ;

            //System.out.println("reach");
        }

        System.out.println(result);
    }
}

import java.io.*;
import java.lang.*;
import java.util.*;
import java.util.ArrayList;
import java.text.DecimalFormat;

public class Main {
    public static void cout(String s)
    {
        System.out.print(s);

    }
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s=in.nextLine();
            int i;
            int ans,c;
            ans=1;
            c=1;
            for(i=1;i<s.length();i++)
            {
                if(s.charAt(i)==s.charAt(i-1))
                {
                    c++;
                    if(c==5)
                    {
                        ans++;
                        c=0;
                    }
                }
                else
                {
                    ans++;
                    c=1;
                }

            }
            if(c>0)
                ans++;
            System.out.println(ans);

        }
    }

}

import java.util.*;

public class Main {

        public static void main(String[] args){
        Scanner input = new Scanner(System.in);

             String s = input.next();
             int count = 0;
             int x = 1;
             if(s.length()==1){
                 System.out.println(1);
             }
             else{
             for (int i = 1; i < s.length(); i++) {

                if(s.charAt(i)== s.charAt(i-1)){
                    x++;
                 if(x==5){
                    count++;
                    x=0;}
                }
                else
                {
                        count++;
                        x=1;
                }

                 if((i==s.length()-1 && x==1) || count==0 && i==s.length()-1 )
                     count++;

            }
             System.out.println(count);
            }
        }

}

import java.util.Scanner;

public class A137 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int res = 0;
        int cnt = 1;
        for (int i = 1 ; i < s.length() ; i++) {
            if (s.charAt(i) == s.charAt(i - 1)) {
                cnt++;
                if (cnt == 5) {
                    res++;
                    cnt = 0;
                }
            } else {
                res++;
                if (cnt == 5) res++;
                cnt = 1;
            }
        }
        if (cnt != 0) res++;
        System.out.println(res);
    }
}

//137/A

import java.util.Scanner;
public class Main {
    public static void main(String[]args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int count = 0;
        int c = 1;
        boolean b = false;
        for (int i = 1 ; i < s.length(); i++) {
            if (s.charAt(i-1) == 'C') b = true;
            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'C')) {
                c++;
                continue;
            }

            if ((s.charAt(i-1) == 'C') && (s.charAt(i) == 'P')) {
                if (c % 5 == 0) {
                    count += 2*(c/5);
                } else {
                    count += 2*((c/5)+1);
                }
                c = 1;
            }// end of if-condition
        }// end of the for loop (i = 0)
        if (c > 1) {
            if (c % 5 == 0) {
                count += (c/5);
            } else {
                count += ((c/5)+1);
            }
        } else {
            if (s.charAt(s.length()-1) == 'C') count++;
        }
        if (s.charAt(s.length()-1) == 'C') b =true;
        if (s.charAt(0) == 'P') count++;
        if (b) {
            System.out.println(count);
        } else {
            System.out.println(count+1);
        }
    }//end of main method
}//end of class

import java.util.Scanner;

/**
 *
 * @author enreina
 */
public class Polycarpus {

    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);

        String input = read.next();
        int visits = 1;
        char currentChar = input.charAt(0);
        int hands = 1;
        for (int i = 1; i < input.length(); i++) {
            if (input.charAt(i) == currentChar && hands < 5) {
                hands++;
            }
            else {
                currentChar = input.charAt(i);
                hands = 0;
                visits++;
            }

        }
        System.out.println(visits);
    }
}

import java.util.Scanner;
public class Polycarpus {
  public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String n = s.next();
        int times = 1;
        int carried_item = 1;
        for(int  i = 1; i < n.length(); i++)
        {
        if(n.charAt(i) == n.charAt(i - 1) && carried_item < 5)
            ++carried_item;
        else
            {
            ++times;
            carried_item = 0;
                }
        }
    System.out.println(times);
    s.close();
    }
}