class Solution { public: int subtractProductAndSum(int n) { int add=0; int prod=1; while(n>0){ int r=n%10; n/=10; prod*=r; add+=r; } int res=prod-add; return res; } };