#include<bits/stdc++.h>
#define ll long long 
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define w(t) ll t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define precision cout<<fixed<<setprecision(10)
const ll mod=1e9+7;
using namespace std;
int main()
{
	IOS
	ll n,s=0,r;
	cin>>n;
  	fo(i,0,n)
    {
      ll a,b;
      cin>>a>>b;
      r=((b*(b+1))/2)-((a*(a-1))/2);
      s=s+r;
    }
  	cout<<s;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int n;
ll x,a[55];
map<ll,ll> mem[55];

ll dfs(const int& i,const ll& v){
    if(i==0)return v==0;
    if(mem[i].find(v)!=mem[i].end())return mem[i][v];
    ll nv=v%a[i];
    mem[i][v]=dfs(i-1,nv);
    if(nv&&a[i]+v!=a[i+1]+nv)mem[i][v]+=dfs(i-1,a[i]-nv);
    return mem[i][v];
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>x;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    cout<<dfs(n,x%a[n])<<endl;

    return 0;
}