class Solution: def maxpro(self, xlist): """ :param xlist: List[int] :return: int """ list_len = len(xlist) if list_len == 0: return 0 buyin = xlist[0] dp = [0] * list_len dp[0] = 0 for i in range(1, list_len): dp[i] = max(dp[i - 1], dp[i - 1] - xlist[i] + buyin) buyin = xlist[i] return dp[list_len - 1] if __name__ == '__main__': s = [int(i) for i in input().split(',')] res = Solution() result = res.maxpro(s) print(result)