
#include<stdio.h>
int main()
{
    int i,D,n;
    char str[100];
    
        scanf("%s",str);
    n=i;
    
    for(i=0;i<=n;i++){
        if('str[i]'=='D')
            D=D+1;
        if(('str[i}'=='P')&&('str[i+1]'=='D'))
              D=D+1;
        if('str[i]'=='P'&&('str[i+1]'=='?'))
           D=D+2;
        if('str[i]'=='D'&&('str[i+1]'=='?'))
            D=D+1;
    }
    printf("%d",D);
}