// Aizu 1173: The Balance of the World
// 2017.9.14 bal4u@uu

#include <stdio.h>

char buf[110], *p;

int parse()
{
//	printf("%s\n", p);
	while (*p) {
		if (*p == '(') {
			if (*(p+1) == ')') p+=2;
			else if (*(p+1) == ']') return 0;
			else {
				p++; if (!parse()) return 0;
				if (*p++ != ')') return 0;
			}
		} else if (*p == '[') {
			if (*(p+1) == ']') p+=2;
			else if (*(p+1) == ')') return 0;
			else {
				p++; if (!parse()) return 0;
				if (*p++ != ']') return 0;
			}
		} else return 1;
	}
	return 1;
}

int main()
{
	int f, ca, cb;
	char t[120], *q;

	while (1) {
		fgets(t, 110, stdin); if (t[0] == '.' && (!t[1] || t[1] == '\n')) break;
		f = 1, ca = cb = 0, p = buf, q = t; while (*q) {
			if      (*q == '(')   ca++, *p++ = *q++;
			else if (*q == ')') { ca--, *p++ = *q++; if (ca < 0) { f = 0; break; } }
			else if (*q == '[')   cb++, *p++ = *q++;
			else if (*q == ']') { cb--, *p++ = *q++; if (cb < 0) { f = 0; break; } }
			else q++;
		}
		*q = 0, p = buf;
		if (ca || cb) f = 0; 
		if (f) f = parse();
		puts(f ? "yes" : "no");
	}
	return 0;
}