Problem:
Score : 100 points

Problem Statement

There is an N-car train.

You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."

Constraints

1 \leq N \leq 100

1 \leq i \leq N

Input

Input is given from Standard Input in the following format:

N i

Output

Print the answer.

Sample Input 1

4 2

Sample Output 1

3

The second car from the front of a 4-car train is the third car from the back.

Sample Input 2

1 1

Sample Output 2

1

Sample Input 3

15 11

Sample Output 3

5

Solution in Pascal (FPC 2.6.2) (judge verdict: Wrong Answer)

var
	s:int64;
	n,k,i,x,y,t,a,p:longint;
	f,f1:array[-200010..200010] of longint;
function min(a,b:longint):longint;
begin
	if a<b then exit(a) else exit(b);
end;
begin
	read(n,k);
	x:=0; y:=0;
	t:=1; p:=0;
	fillchar(f1,sizeof(f1),$7f);
	for i:=1 to n do
	begin 
		read(a);
		if a>0 then inc(x);
		if a<0 then inc(y);
		if a=0 then dec(k);
		if (a>0) and (f[i-1]<=0) then t:=i;
		if a<>0 then
		begin 
			inc(p);
			f[p]:=a;
		end;
	end;
	if x=0 then
	begin
		writeln(-f[p-k+1]);
		halt;
	end;
	if y=0 then
	begin
		writeln(f[k]);
		halt;
	end;
	if p=k then
	begin
		if abs(f[1])<abs(f[p]) then writeln(abs(f[1])*2+abs(f[p]))
		else writeln(abs(f[p])*2+abs(f[1]));
		halt;
	end;
	s:=$7f;
	for i:=1 to p do f1[i-t]:=abs(f[i]);
	y:=0-y;
	if x>=k then s:=min(s,f1[k-1]);
	if 0-y>=k then s:=min(s,f1[0-k]);
	for i:=-min(-y,k) to -1 do
		if i*(k+i-1)<=0 then
			s:=min(s,f1[i]*2+f1[k+i-1]);
	for i:=1 to min(x-1,k-1) do
		if i*(k-i-1)>=0 then
			s:=min(s,f1[i]*2+f1[0-(k-i-1)]);
	writeln(s);
end.