// Arup Guha
// 9/29/2017
// Solution? to 2015 NCPC Problem C: Cryptographer's Conundrum

import java.util.*;

public class conundrum {

	public static void main(String[] args) {

		// Read in string.
		String per = "PER";
		Scanner stdin = new Scanner(System.in);
		String cipher = stdin.next();

		// Just compare with index mod 3...
		int res = 0;
		for (int i=0; i<cipher.length(); i++)
			if (cipher.charAt(i) != per.charAt(i%3))
				res++;

		System.out.println(res);
	}
}