1
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String s = cin.next();
int n = s.length();
int res = 0;
for (int i = 0; i < n; ) {
int j = i;
if ((s.charAt(j) < '0' || s.charAt(j) > '9') && s.charAt(j) != '-') {
i ++;
continue;
}
if (s.charAt(j) == '-') {
j ++;
int t = 0;
while (s.charAt(j) >= '0' && s.charAt(j) <= '9') {
t = t * 10 + (s.charAt(j) - '0');
j++;
}
t = -t;
res += t;
i = j;
} else {
res += s.charAt(j) - '0';
j ++;
i = j;
}
}
System.out.println(res);
}
}
2
3
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String ss = cin.next();
String[] s = ss.split(",");
int n = s.length;
int[] a = new int[n], b = new int[n];
for (int i = 0; i < n; ++i) {
a[i] = Integer.parseInt(s[i]);
b[i] = Integer.parseInt(s[i]);
}
Arrays.sort(b);
int[] res = new int[n];
Arrays.fill(res, -1);
int j = 0;
for (int i = n - 1; i >= 0; --i) {
while (true) {
if (j == n) {
j = 0;
}
if (a[j] == b[i] && res[j] == -1) {
break;
}
j++;
}
res[j] = n - i - 1;
}
for (int i = 0; i < n; ++i) {
System.out.print(res[i]);
if (i != n - 1) {
System.out.print(",");
}
}
}
}