using System.Collections.Generic; using System.Linq; using System; public class Hello { public static void Main() { var ans = new List(); var s = Console.ReadLine().Trim(); var sL = s.Length; var t = s; for (int i = 0; i < sL; i++) { if (t[0] != '+' && t[0] != '-' && t[sL - 1] != '+' && t[sL - 1] != '-') ans.Add(getAns(t)); t = t.Substring(1) + t[0]; } Console.WriteLine(ans.Max()); } public static int getAns(string s) { string[] s2 = s.Split('+', '-'); var a = new List(); for (int i = 0; i < s2.Length; i++) a.Add(int.Parse(s2[i])); var b = new List(); for (int i = 0; i < s.Length; i++) if (s[i] == '+') b.Add(0); else if (s[i] == '-') b.Add(1); int ans; if (b[0] == 0) ans = a[0] + a[1]; else ans = a[0] - a[1]; for (int i = 1; i < b.Count(); i++) { if (b[i] == 0) ans += a[i + 1]; else ans -= a[i + 1]; } return ans; } }