/*--------------------------------------------------------------*/
/* ACM ICPC 2007-2008                                           */
/* Northeastern European Regional Contest                       */
/* St Petersburg - Barnaul - Tashkent - Batumi, November 28, 200*/
/*--------------------------------------------------------------*/
/* Problem E. Equation                                          */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Roman Elizarov                         */
/*--------------------------------------------------------------*/
 
/*
    Solution for NEERC'2007 Problem E: Equation
    (C) Roman Elizarov
    Note: this solution attempts to check correctness of the input
*/

import java.io.*;
import java.util.*;

public class equation_re {

	public static void main(String[] args) throws Exception {
		new equation_re().go();
	}

	static long gcd(long p, long q) {
		p = Math.abs(p);
		q = Math.abs(q);
		while (p != 0) {
			long x = q % p;
			q = p;
			p = x;
			// assert p < q
		}
		return q;
	}

	public static class Fraction {
		final long p;
		final long q;

		public static final Fraction ZERO = new Fraction(0, 1);
		public static final Fraction ONE = new Fraction(1, 1);

		public static final Fraction NONE = new Fraction(1, 0);
		public static final Fraction MULTIPLE = new Fraction(0, 0);

		public Fraction(long p, long q) {
			long g = Math.max(1, gcd(p, q));
			if (q < 0)
				g = -g;
			this.p = p / g;
			this.q = q / g;
		}

		public boolean isZero() {
			return p == 0;
		}

		public boolean isLegal() {
			return q != 0;
		}
		
		public String toString() {
			return q == 0 ? p == 0 ? "MULTIPLE" : "NONE" : "X = " + p + "/" + q;
		}

		Fraction neg() {
			assert isLegal();
			return new Fraction(-p, q);
		}

		Fraction add(Fraction f) {
			assert isLegal() && f.isLegal();
			return new Fraction(p * f.q + q * f.p, q * f.q);
		}

		Fraction sub(Fraction f) {
			assert isLegal() && f.isLegal();
			return new Fraction(p * f.q - q * f.p, q * f.q);
		}

		Fraction mul(Fraction f) {
			assert isLegal() && f.isLegal();
			return new Fraction(p * f.p, q * f.q);
		}

		Fraction div(Fraction f) {
			assert isLegal() && f.isLegal();
			if (f.isZero())
				throw new ArithmeticException("division by zero");
			return new Fraction(p * f.q, q * f.p);
		}

	}

	public static class Poly {
		final Fraction a;
		final Fraction b;
		final Fraction c;
		final Fraction d;

		public Poly(Fraction a, Fraction b, Fraction c, Fraction d) {
			if (b.isZero() && d.isZero()) { // normalize consts
				a = a.div(c);
				c = Fraction.ONE;
			}
			if (a.isZero() && b.isZero()) { // normalize zero
				assert !c.isZero() || !d.isZero();
				c = Fraction.ONE;
				d = Fraction.ZERO;
			}
			this.a = a;
			this.b = b;
			this.c = c;
			this.d = d;
		}

		public String toString() {
			return "(" + a + (b.isZero() ? "" : "+" + b + "*x") + ")/(" + c + (d.isZero() ? "" : "+" + d + "*x") + ")";
		}

		public boolean isConstant() {
			return b.isZero() && d.isZero();
		}

		public Poly neg() {
			return new Poly(a.neg(), b.neg(), c, d);
		}

		public Poly inv() {
			if (isConstant() && a.isZero())
				throw new ArithmeticException("division by constant zero");
			return new Poly(c, d, a, b);
		}

		public Poly add(Poly o) {
			if (o.isConstant())
				return new Poly(a.add(c.mul(o.a)), b.add(d.mul(o.a)), c, d);
			else if (isConstant())
				return o.add(this);
			else
				throw new IllegalArgumentException();
		}

		public Poly sub(Poly o) {
			return add(o.neg());
		}

		public Poly mul(Poly o) {
			if (o.isConstant())
				return new Poly(a.mul(o.a), b.mul(o.a), c, d);
			else if (isConstant())
				return o.mul(this);
			else
				throw new IllegalArgumentException();
		}

		public Poly div(Poly o) {
			return mul(o.inv());
		}

		public Fraction solve() {
			if (b.isZero() && d.isZero()) // const
				return a.isZero() ? Fraction.MULTIPLE : Fraction.NONE;
			else if (!b.isZero() && d.isZero()) // (a + b*x) / c = 0
				return a.neg().div(b);
			else if (b.isZero() && !d.isZero()) // a / (c + d*x) = 0
				return Fraction.NONE;
			else { // (a + b*x) / (c + d*x)
				Fraction x = a.neg().div(b);
				Fraction y = c.neg().div(d);
			    if (x.sub(y).isZero())
					return Fraction.NONE;
				return x;
			}
		}
	}

	void go() throws Exception {
		// read input
		BufferedReader in = new BufferedReader(new FileReader("equation.in"));
		String eq = in.readLine();
		assert in.readLine() == null;
		in.close();

		// solve
		Stack<Poly> stack = new Stack<Poly>();
		List<Fraction> exclude = new ArrayList<Fraction>();

		int xcnt = 0;
		for (int i = 0; i < eq.length(); i++) {
			char c = eq.charAt(i);
			if (i % 2 == 1) {
				assert c == ' ';
				continue;
			}
			Poly a;
			Poly b;
			switch (c) {
			case 'X':
				stack.push(new Poly(Fraction.ZERO, Fraction.ONE, Fraction.ONE, Fraction.ZERO));
				xcnt++;
				break;
			case '+':
				b = stack.pop();
				a = stack.pop();
				stack.push(a.add(b));
				break;
			case '-':
				b = stack.pop();
				a = stack.pop();
				stack.push(a.sub(b));
				break;
			case '*':
				b = stack.pop();
				a = stack.pop();
				stack.push(a.mul(b));
				break;
			case '/':
				b = stack.pop();
				a = stack.pop();
				Fraction x = b.solve();
				if (x.isLegal())
					exclude.add(x);
				stack.push(a.div(b));
				break;
			default:
				if (c >= '0' && c <= '9') {
					stack.push(new Poly(new Fraction(c - '0', 1), Fraction.ZERO, Fraction.ONE, Fraction.ZERO));
				} else
					throw new IllegalArgumentException("Invalid char: " + c);
			}
		}
		assert xcnt <= 1;
		assert stack.size() == 1;

		Fraction x = stack.pop().solve();
		if (x.isLegal())
			for (Fraction y : exclude)
				if (x.sub(y).isZero()) {
					x = Fraction.NONE;
					break;
				}

		// write output
		PrintWriter out = new PrintWriter("equation.out");
		out.println(x);
		out.close();
	}
}

