B;main(){scanf("%d%d%d",&B,&B,&B);printf("%d",B++*B/2%17);}