using System; using System.Text.RegularExpressions; namespace y { class Program { static void Main(string[] args) { var s = Console.ReadLine(); int a = 0; while (!int.TryParse(s, out a)) { s = s.Replace("--", "+").Replace("+-", "-"); s = Ca(s); } Console.WriteLine(a); } static string Ca(string s) { string a = Regex.Match(s, @"\(.*?\)").Value; if (a.Length == 0) a = s; int r = 0; bool isMinus = false; for (int j = 0; j < a.Length; j++) { if (a[j] == '-') { isMinus = true; continue; } if (a[j] >= '0' && a[j] <= '9') { string y = a[j].ToString(); while (j < a.Length - 1 && (a[j + 1] >= '0' && a[j + 1] <= '9')) { y += a[j + 1]; j++; } if (!isMinus) { r += int.Parse(y); } else { r -= int.Parse(y); isMinus = false; } } } return s.Replace(a, r.ToString()); } } }