#include <algorithm>
#include <iostream>
using namespace std;

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	s.erase(unique(begin(s), remove_if(begin(s), end(s), [](char c) { return c != 'A' && c != 'Z'; })), end(s));
	if(!s.empty() && s.front() == 'Z') s.erase(begin(s));
	if(!s.empty() && s.back() == 'A') s.erase(end(s) - 1);
	cout << (s.empty() ? "-1" : s) << endl;

	return EXIT_SUCCESS;
}