procedure Diff(string a):string b
i:=pos("+",a);
if i > 0 then return(Diff(copy(a,1,i-1))"+"Diff(copy(a,i+1,len(a)))
e:=pos("*",a)
x:=copy(a,1,e-1) y:=copy(a,e+1,len(e))
if e>0 return (Diff(x)"*"y"+" Diff(y)"*"x)
if a="x" return("1") else return ("0")