# include<stdio.h> # include <algorithm> # include <string.h> # include <iostream> using namespace std; int main() { int n,m,i,j,k; int c1[110],c2[110]; int a[110],b[110]; while(~scanf("%d%d",&n,&m)) { for(i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]); memset(c1,0,sizeof(c1)); memset(c2,0,sizeof(c2)); for(i=a[0];i<=b[0];i++)//第一种水果 c1[i]=1; for(i=1;i<n;i++) { for(j=0;j<=m;j++)//买m种水果组成的拼盘 { for(k=a[i];k<=b[i];k++)//i类水果数量 从a[]到b[] { c2[j+k]+=c1[j]; } } for(j=0;j<=m;j++) { c1[j]=c2[j]; c2[j]=0; } } printf("%d ",c1[m]); } return 0; }