using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace foryuki { class Program { static void Main(string[] args) { var S = Console.ReadLine().ToList(); int max = int.MinValue; for (int i = 0; i < S.Count(); i++) { if (char.IsNumber(S[0]) && char.IsNumber(S[S.Count - 1])) { max = Math.Max(max, a(S)); } S.Add(S[0]); S.RemoveAt(0); } Console.WriteLine(max); } static int a(List s) { int i = 0; int re = 0; string x = ""; bool isPlus = true; while (true) { x = ""; while (char.IsNumber(s[i])) { x += s[i]; i++; if (i > s.Count - 1) { break; } } if (isPlus) { re += int.Parse(x); } else { re -= int.Parse(x); } if (i > s.Count - 1) { break; } if (s[i] == '+') { isPlus = true; } else { isPlus = false; } i++; } return re; } //------------------------------------------------------------- static int[] ConvertStringArrayToIntArray(string[] array) { return Array.ConvertAll(array, str => int.Parse(str)); } static List ConvertStringArrayToIntList(string[] str) { var list = new List(); foreach (var c in str) { list.Add(int.Parse(c)); } return list; } } }