【Basic Level】
*1016
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cctype>
#include <vector>
using namespace std;
int main()
{
int a, b, a1, b1, sum = 0, sum1 = 0;
cin >> a >> a1 >> b >> b1;
int f = 1;
while (a > 0)
{
if (a % 10 == a1)
{
if (f)
{
sum = a1;
f = 0;
}
else
sum = sum * 10 + a1;
}
a /= 10;
/* code */
}
f = 1;
while (b > 0)
{
if (b % 10 == b1)
{
if (f)
{
sum1 = b1;
f = 0;
}
else
sum1 = sum1 * 10 + b1;
}
b /= 10;
/* code */
}
cout << sum + sum1 << endl;
//system("pause");
return 0;
}