#include using namespace std; int main() {int x,y,z,c,p; do {cin>>x>>y>>z; if(x==y&&y==z&&z==0) return 0; p=1;c=0; while(x) {if(x%10==y) c+=z*p; else c+=(x%10)*p; x/=10; p*=10;} cout<