Unable to pass all test case

#include
using namespace std;
int main() {
long long n;
cin>>n;
long long ans = 0;
long long p =1;
while(n>0){

	long long d = n%10;
	if(d==0){
		d=5;
	}
	ans += d * p;
	 
	p  *= 10;
	n/=10;
}
cout<<ans<<endl;
return 0;

}