n,m=map(int,input().split())
dp=[[0]*2 for i in range(n)]
ans,x=0,0
for i in range(n):
  a,b=map(int,input().split())
  dp[i][0]=a
  dp[i][1]=b
dp.sort()
while m>0:
  dp[x][1]-=1
  ans+=dp[x][0]
  m-=1
  if dp[x][1]==0:
    x+=1
print(ans) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [0]*2 for i in range(n) for i in range(n) i range(n) range n for i in range(n) [0]*2 [0] 0 2 dp=[[0]*2 for i in range(n)] dp [[0]*2 for i in range(n)] ans,x=0,0 ans 0 x 0 for i in range(n):
  a,b=map(int,input().split())
  dp[i][0]=a
  dp[i][1]=b i range(n) range n a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b dp[i][0]=a dp[i][0] [i] dp i 0 a dp[i][1]=b dp[i][1] [i] dp i 1 b dp.sort() dp.sort dp sort while m>0:
  dp[x][1]-=1
  ans+=dp[x][0]
  m-=1
  if dp[x][1]==0:
    x+=1 m>0 m 0 dp[x][1]-=1 dp[x][1] [x] dp x 1 1 ans+=dp[x][0] ans dp[x][0] [x] dp x 0 m-=1 m 1 if dp[x][1]==0:
    x+=1 dp[x][1]==0 dp[x][1] [x] dp x 1 0 x+=1 x 1 print(ans) print ans ans+=dp[x][0] dp[x][0] ans m-=1 1 m dp=[[0]*2 for i in range(n)] [[0]*2 for i in range(n)] dp n,m=map(int,input().split()) map(int,input().split()) n ans,x=0,0 0 ans a,b=map(int,input().split()) map(int,input().split()) a x=0,0 0 x b=map(int,input().split()) map(int,input().split()) b x+=1 1 x m=map(int,input().split()) map(int,input().split()) m
n,m=map(int,input().split())
dp=[[0]*2 for i in range(n)]
ans,x=0,0
for i in range(n):
  a,b=map(int,input().split())
  dp[i][0]=a
  dp[i][1]=b
dp.sort()
while m>0:
  dp[x][1]-=1
  ans+=dp[x][0]
  m-=1
  if dp[x][1]==0:
    x+=1
print(ans)
