35 lines
897 B
Java
35 lines
897 B
Java
import java.util.*;
|
|
|
|
public class _1541 {
|
|
public static void main(String[] args) {
|
|
Scanner sc = new Scanner(System.in);
|
|
String[] input = sc.nextLine().split("-");
|
|
sc.close();
|
|
|
|
ArrayList<Integer> num = new ArrayList<Integer>();
|
|
for(String s : input) {
|
|
int sum = 0;
|
|
if(s.contains("+")){
|
|
for(String n : s.split("\\+")){
|
|
sum += Integer.parseInt(n);
|
|
}
|
|
}
|
|
else {
|
|
sum += Integer.parseInt(s);
|
|
}
|
|
num.add(sum);
|
|
}
|
|
if(num.size()==1) {
|
|
System.out.println(num.get(0));
|
|
}
|
|
else {
|
|
int a = num.get(0);
|
|
int b = 0;
|
|
for(int i=1; i<num.size(); i++){
|
|
b += num.get(i);
|
|
}
|
|
System.out.println(a-b);
|
|
}
|
|
}
|
|
}
|