#include<stdio.h>
int main(void)
{
/*********Begin*********/
float x;
scanf("%f",&x);
if(x<0&&x!=-3)
{
x=(x*x+x-6);
printf("%.3f",x);
}
else if(x<=10&&x>=0&&x!=2&&x!=3)
{
x=(x*x-5*x+6);
printf("%.3f",x);
}
else
{
x=(x*x-x-1);
printf("%.3f",x);
}
/*********End**********/
return 0;
}