#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

struct invalid_char { char c; };
template <typename It>
std::vector<int> split_values(It beg, It end) {
	std::vector<int> ret;
	std::transform(beg, end, std::back_inserter(ret), [](char c) {
		if (c >= 'a' && c <= 'z') return c - 'a' + 1;
		if (c >= 'A' && c <= 'Z') return c - 'A' + 1;
		throw invalid_char{c};
	});
	std::partial_sum(ret.begin(), ret.end(), ret.begin());
	std::partial_sum(ret.begin(), ret.end(), ret.begin());
	return ret;
}

int main() {
	std::string s;
	while (std::cin >> s) {
		if (s.length() <= 3) {
			std::cout << s << " does not balance.\n";
			continue;
		}
		auto forward = split_values(s.begin(), s.end());
		auto back = split_values(s.rbegin(), s.rend());
		auto f = forward.begin(), fend = forward.end() - 2;
		for (auto b = back.rbegin() + 2; f != fend && *f != *b; ++f, ++b);
		if (f != fend) {
			auto len = std::distance(forward.begin(), f) + 1;
			std::cout << s.substr(0, len) << ' ' << s[len] << ' ' << s.substr(len+1)
				<< " - " << *f << '\n';
		} else {
			std::cout << s << " does not balance.\n";
		}
	}
	return 0;
}