#include <iostream>
#include <cstring>
using namespace std;
bool isIncreasing(char cards[]) {
int length = strlen(cards);
for (int i = 2; i < length; i += 2) {
char previousCard[3] = {cards[i - 2], cards[i - 1], 0};
char currentCard[3] = {cards[i], cards[i + 1], 0};
if (strcmp(currentCard, previousCard) < 0) {
return false;
}
}
return true;
}
int main() {
char cards[100];
cin >> cards;
cout << isIncreasing(cards);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmJvb2wgaXNJbmNyZWFzaW5nKGNoYXIgY2FyZHNbXSkgewogICAgaW50IGxlbmd0aCA9IHN0cmxlbihjYXJkcyk7CiAgICBmb3IgKGludCBpID0gMjsgaSA8IGxlbmd0aDsgaSArPSAyKSB7CiAgICAgICAgY2hhciBwcmV2aW91c0NhcmRbM10gPSB7Y2FyZHNbaSAtIDJdLCBjYXJkc1tpIC0gMV0sIDB9OwogICAgICAgIGNoYXIgY3VycmVudENhcmRbM10gPSB7Y2FyZHNbaV0sIGNhcmRzW2kgKyAxXSwgMH07CiAgICAgICAgaWYgKHN0cmNtcChjdXJyZW50Q2FyZCwgcHJldmlvdXNDYXJkKSA8IDApIHsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiB0cnVlOwp9CgppbnQgbWFpbigpIHsKICAgIGNoYXIgY2FyZHNbMTAwXTsKICAgIGNpbiA+PiBjYXJkczsKICAgIGNvdXQgPDwgaXNJbmNyZWFzaW5nKGNhcmRzKTsKfQ==