#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int d[100],w[100],s,n;
int f[100][100][3];//如果关闭一个区间的灯,最后人一定在这个区间的左边或右边,关了左边或右边的灯去中间没必要。
//f[i][j][0]表示关了[i,j]区间的灯最后人在i点的最优值,f[i][j][1]表示关了[i,j]区间的灯最后人在j点的最优值
int main()
{
scanf("%d%d",&n,&s);
for(int i=1;i<=n;i++)
scanf("%d%d",&d[i],&w[i]),w[i]+=w[i-1];
memset(f,127/3,sizeof(f));
f[s][s][0]=f[s][s][1]=0;
for(int i=s;i>=1;i--)
for(int j=i+1;j<=n;j++)
{
f[i][j][0]=min(f[i+1][j][0]+(d[i+1]-d[i])*(w[n]-(w[j]-w[i])),f[i][j][0]);
f[i][j][0]=min(f[i+1][j][1]+(d[j]-d[i])*(w[n]-(w[j]-w[i])),f[i][j][0]);
f[i][j][1]=min(f[i][j-1][1]+(d[j]-d[j-1])*(w[n]-(w[j-1]-w[i-1])),f[i][j][1]);
f[i][j][1]=min(f[i][j-1][0]+(d[j]-d[i])*(w[n]-(w[j-1]-w[i-1])),f[i][j][1]);
}
printf("%d",min(f[1][n][1],f[1][n][0]));
}