#!/usr/bin/python path = str(input()) print(abs(path.index('P') - path.index('H')) - 1)