/*--------------------------------------------------------------*/
/* ACM ICPC 2009-2010, NEERC                                    */
/* Northern Subregional Contest                                 */
/* St Petersburg, October 17, 2009                              */
/*--------------------------------------------------------------*/
/* Problem A. Auxiliary Question of the Universe                */
/*                                                              */
/* Original idea         Dmitry Shtukenberg, Mikhail Dvorkin    */
/* Problem statement     Dmitry Shtukenberg                     */
/* Testset               Georgiy Korneev                        */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Dmitry Shtukenberg                     */
/*--------------------------------------------------------------*/
 
#include <stdio.h>
//#include <process.h>
#include <stdlib.h>
#include <memory.h>
#include <ctype.h>
#include <string.h>

//#define RANDOM

char symbols[] = "0+()";
char buf [5000];
char buf1 [5000];

#define ASSERT(cond) if (!(cond)) { \
  fprintf (stderr, "Debugging assertion: " #cond "\n"); exit (239); \
}

int blocked [65536];

void build_blocked () {
	unsigned short idx;
	char* ptr = (char*) &idx;
	memset (blocked, 0, sizeof (blocked));

	for (ptr [0] = 0; ~ptr [0]; ptr [0] ++)
		for (ptr [1] = 0; ~ptr [1]; ptr [1] ++) {
			if ((isdigit (ptr [0]) && (ptr [1] == '(')) ||
			    ((ptr [0] == '(' || ptr [0] == '[') && 
			      (ptr [1] == '+' || ptr [1] == '*' || ptr [1] == ')' || ptr [1] == ']' || !ptr [1])) ||
			    ((ptr [0] == ')' || ptr [0] == ']') && 
			      (isdigit (ptr [1]) || ptr [1] == '(') || ptr [1] == '[') ||
			    ((ptr [0] == '+') && 
			      (ptr [1] == ')' || ptr [1] == ']' || !ptr [1] || ptr [1] == '+' || ptr [1] == '*'))) 
			{
				blocked [idx] |= 1;
			}
			if (ptr [0] == '(') blocked [idx] += 65536;
			if (ptr [0] == ')') blocked [idx] -= 65536;
		}
}

int count_errors (char* ptr) {
	unsigned char a = ptr [0];
	unsigned char b;

	int brackets = 0;
	int u = 0;

	if (a == '+' || a == '*' || a == ')' || a == ']') u ++;

	do {
		b = *++ptr;
		u += blocked [(int) b * 256 + (int) a];
		if (u >> 16 < 0) { brackets ++; u &= 65535; }
	} while (a = b);

	return u + (brackets << 16);
}

int main () {
	FILE* fout;
	char* p;
	int errors;
	int len;

	FILE* fin = stdin;
	memset (buf, 0, sizeof (buf));
	fscanf (fin, "%1023s", buf);
	fclose (fin);

	ASSERT (strlen (buf) <= 1000);
	ASSERT (strlen (buf) > 0);
	for (p = buf; *p != '\0'; p++) {
		if (*p >= '0' && *p <= '9') continue;
		if (*p == '(' || *p == ')' || *p == '+') continue;
		ASSERT (!"Unexpected symbol");
	}

	build_blocked ();
	errors = count_errors (buf);
	len = strlen (buf);
	while (errors > 0) {
#ifdef RANDOM
		char sym = rand () % 4;
		int pos = rand () % (len + 1);
#else
		char sym;
		int pos;
		for (pos = 0; pos <= len; pos++) for (sym = 0; sym < 4; sym++) {
#endif
		int errors1;

		memcpy (buf1, buf, pos);
		memcpy (buf1 + pos + 1, buf + pos, len - pos + 1);
		buf1 [pos] = symbols [sym];

		errors1 = count_errors (buf1);
		
		if (errors1 < errors) {
			errors = errors1;
			memcpy (buf + pos, buf1 + pos, len - pos + 2);
			len ++;
		}
#ifndef RANDOM
		}
#endif
	}

	fout = stdout;
	fprintf (fout, "%s\n", buf);
	fclose (fout);
	
	return 0;
}
