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