import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
String str = sc.readLine();
int result = process(str);
System.out.println(result);
}
private static int process(String str) {
if ("2147483648".equals(str) || !isValid(str)) {
return 0;
}
if ("-2147483648".equals(str)) {
return -2147483648;
}
int negetive = -1;
if (str.charAt(0) == '-') {
negetive = 1;
str = str.substring(1);
}
if (!isValidDigit(str)){
return 0;
}
char[] ch = str.toCharArray();
int res = 0;
int digit = 1;
for (int i = ch.length - 1; i >= 0; i--) {
int number = ch[i] - '0';
res += number * digit;
digit = digit * 10;
}
if (negetive == 1) {
return -res;
} else {
return res;
}
}
public static boolean isValidDigit(String str){
String temp = "2147483648";
if (str.length()>temp.length()){
return false;
}
else if(str.length()==temp.length()){
char[] tempCh = temp.toCharArray();
char[] strCh = str.toCharArray();
for (int i = 0; i < strCh.length; i++) {
if (strCh[i]>tempCh[i]){
return false;
}
}
}
return true;
}
public static boolean isValid(String str) {
char[] chars1 = str.toCharArray();
if (chars1[0] != '-' && (chars1[0] < '0' || chars1[0] > '9')) {
return false;
}
if (chars1[0] == '-' && (chars1.length == 1 || chars1[1] == '0')) {
return false;
}
if (chars1[0] == '0' && chars1.length > 1) {
return false;
}
for (int i = 1; i < chars1.length; i++) {
if (chars1[i] < '0' || chars1[i] > '9') {
return false;
}
}
return true;
}}

京公网安备 11010502036488号