Changed constants to long long type to avoid overflows