program CloseTheLight;
uses math;
var n,c,i,p,j,k,v1,a:longint;
v,s:array[0..1000] of longint;
f:array[0..1000,0..1000,0..1] of longint;
begin
read(n,c);
for i:=1 to n do
begin
read(v[i],a);
s[i]:=s[i-1]+a;
end;
filldword(f,sizeof(f) div 4,maxlongint);
f[c,c,1]:=0;
f[c,c,0]:=0;
for p:=0 to n-1 do
for i:=1 to n-p do
begin
j:=i+p;
for k:=0 to 1 do
begin
if k=0 then v1:=i else v1:=j;
if f[i,j,k]<maxlongint then
begin
if i>0 then f[i-1,j,0]:=min(f[i-1,j,0],
f[i,j,k]+(s[i-1]+s[n]-s[j])*(v[v1]-v[i-1]));
if j<n then f[i,j+1,1]:=min(f[i,j+1,1],
f[i,j,k]+(s[i-1]+s[n]-s[j])*(v[j+1]-v[v1]));
end;
end;
end;
writeln(min(f[1,n,0],f[1,n,1]));
end.