read str
while [ ! $(echo $str | grep ?) = "" ]
do
        str=`echo $str | sed "s;??D;DPD;g; s;??P;DDP;g; s;?D?;PD?;g; s;?P?;DPD;g; s;D??;DPD;g; s;P??;PD?;g; "`
        str=`echo $str | sed "s;?DD;PDD;g; s;?DP;PDP;g; s;?PD;DPD;g; s;?PP;DPP;g; s;D?D;DPD;g; s;D?P;DDP;g; s;DD?;DDD;g; s;DP?;DPD;g; s;P?D;PDD;g; s;P?P;PDP;g; s;PD?;PDD;g; s;PP?;PPD;g; "`
done
echo $str