import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNextLine()){
String str = "";
str = sc.nextLine();
if(str.charAt(str.length() - 1) == '@'){
System.out.println(str.substring(0,str.length() - 1));
}
else{
HashMap<String,Integer> map = new HashMap<String,Integer>();
String a[] = str.split("@");
String big[] = a[0].split(",");
String small[] = a[1].split(",");
for(int i = 0;i < big.length;i++){
String big1[] = big[i].split(":");
int num1 = Integer.parseInt(big1[1]);
map.put(big1[0],num1);
}
for(int j = 0;j < small.length;j++){
String small1[] = small[j].split(":");
int num2 = Integer.parseInt(small1[1]);
if(map.get(small1[0]) <= num2){
map.remove(small1[0]);
}
else{
map.put(small1[0],map.get(small1[0]) - num2);
}
}
String res = "";
for(String ss : map.keySet()){
res = res+ss+":"+map.get(ss)+",";
}
System.out.println(res.substring(0,res.length() - 1));
}
}
}
}