#include #include using namespace std; string n; char c1, c2; void read (istream& in) { in >> n >> c1 >> c2; } int main() { read(cin); while (n != "0" || c1 != '0' || c2 != '0') { for (unsigned int i = 0 ; i < n.size(); ++i) if (n[i] == c1) n[i] = c2; if (n == "0") cout << "0\n"; else { unsigned int j; for (j = 0; j < n.size() && n[j] == '0'; ++j); cout << n.substr(j, distance(n.begin()+j, n.end())) << "\n"; } read(cin); } return 0; }