import java.util.*;
import java.util.regex.*;
class Test
{
{
String text
= "asd ${ITEM_NAME} asd ${KEK} asdasd ${ITEM_NAME_2} \n ${ITEM_NAME} asd ${KEK} asdasd ${ITEM_NAME_2}"; Pattern p = Pattern.compile("\\$\\{([^{}]*)}");
Matcher m = p.matcher(text);
Set<String> res = new HashSet<>();
while(m.find()) {
res.add(m.group(1));
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS51dGlsLnJlZ2V4Lio7CgpjbGFzcyBUZXN0CnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN0cmluZyB0ZXh0ID0gImFzZCAke0lURU1fTkFNRX0gYXNkICR7S0VLfSBhc2Rhc2QgJHtJVEVNX05BTUVfMn0gXG4gJHtJVEVNX05BTUV9IGFzZCAke0tFS30gYXNkYXNkICR7SVRFTV9OQU1FXzJ9IjsKCQlQYXR0ZXJuIHAgPSBQYXR0ZXJuLmNvbXBpbGUoIlxcJFxceyhbXnt9XSopfSIpOwoJICAgIE1hdGNoZXIgbSA9IHAubWF0Y2hlcih0ZXh0KTsKCSAgICBTZXQ8U3RyaW5nPiByZXMgPSBuZXcgSGFzaFNldDw+KCk7CgkgICAgd2hpbGUobS5maW5kKCkpIHsKCSAgICAJcmVzLmFkZChtLmdyb3VwKDEpKTsKCSAgICB9CgkgICAgU3lzdGVtLm91dC5wcmludGxuKHJlcyk7Cgl9Cn0=