#include using namespace std; #define REP(i,N) for(i=0;i P; typedef struct{ int first; int second; int third; }T; //昇順 bool comp_Se(T& l, T& r){ return l.second < r.second; } int main(void){ int N; ll L; cin >> N >> L; vector > v(2*N); int i; REP(i,N){ cin >> v[i].first; v[i].second = 0; } REP(i,N){ cin >> v[N+i].first; v[N+i].second = 1; } sort(v.begin(),v.end()); int count=0,max=0,end = v[v.size()-1].first; pair p; REP(i,v.size()){ if(!v[i].second && count >= 0) count--; else if(v[i].second == 1){ count++; if(count==0) p=v[i]; } if(count>=max){ max=count; end = p.first; } } ll ans = (ll)max*L; ans += (ll)end; cout << ans << endl; return 0; }