#include <stdio.h>
#include <stdlib.h>// 求最大公因数
int gcd(int a, int b)
{return b == 0? a : gcd(b, a % b);
}// 化简分数
void simplify(int *num, int *den)
{int g = gcd(*num, *den);*num /= g;*den /= g;if (*den < 0) {*num *= -1;*den *= -1;}
}// 分数相加
int add_num(int a, int b, int c, int d)
{return a * d + c * b;
}int add_den(int b, int d)
{return b * d;
}// 分数相减
int subtract_num(int a, int b, int c, int d)
{return a * d - c * b;
}int subtract_den(int b, int d)
{return b * d;
}// 输出分数
void printFraction(int num, int den)
{if (den == 1) {printf("%d\n", num);} else if (num > den) {printf("%d+%d/%d\n", num / den, num % den, den);} else if (num < 0 && abs(num) > den) {int o,p,q;o=abs(num)/den +1;p=abs(num)%den;q=den-p;printf ("-%d+%d/%d\n",o,q,den);}else {printf("%d/%d\n", num, den);}
}int main()
{int a,b,c,d;char op;while (scanf ("%d/%d%c%d/%d",&a,&b,&op,&c,&d)!=EOF){int e,f;if (op=='+'){e=add_num (a,b,c,d);f=add_den (b,d);}else{e=subtract_num(a,b,c,d);f=subtract_den (b,d);}simplify (&e,&f);printFraction (e,f);}return 0;
}