#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdint.h>

int main(int argc, char **argv){
	double margin_req = 148.5;
	double comm_one_way_per_contract = 2.51;
	double usd_short = 0;
	double num_need_to_liq = 0;
	double usd_freed = 0;
	double appreciation = 0;
	uint32_t num1 = 0;

	if(argc == 5){
		margin_req = atof(argv[1]);
		comm_one_way_per_contract = atof(argv[2]);
		usd_short  = atof(argv[3]);
		appreciation = atof(argv[4]);
        }else{
              	printf("wrong usage\n");
                printf(" ./meetcall [margin req per contract] [commission per contract one way] [usd short] [usd appreciation]\n");
                exit(0);
        }
	//n = (s + 2.51n) / m
	//n=sm−2.51

	//num_need_to_liq = usd_short*margin_req-comm_one_way_per_contract;
	for(num1=0; num1<1000; num1++){
		usd_freed = margin_req*num1 - comm_one_way_per_contract*num1;

		if(usd_freed>(usd_short-appreciation)){
			num_need_to_liq = num1;
			break;
		}
	}

	printf("%lf\n", num_need_to_liq);





	return 0;
}
