#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a==b+c+d)return puts("Yes"),0;
	if(b==a+c+d)return puts("Yes"),0;
	if(c==b+a+d)return puts("Yes"),0;
	if(d==b+c+a)return puts("Yes"),0;
	if(b+a==c+d)return puts("Yes"),0;
	if(a+c==b+d)return puts("Yes"),0;
	if(b+c==a+d)return puts("Yes"),0;
	puts("No");
	return 0;
}

#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define RI register int
typedef long long LL;
#define int LL 

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

namespace IO {
  char buf[1000000], *p1 = buf, *p2 = buf;
  inline char gc() {
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
    return p1 == p2 ? EOF : *(p1++);
  }
  template <class T> inline void read(T &n) {
    n = 0; RI ch = gc(), f;
    while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
    f = (ch == '-' ? ch = gc(), -1 : 1);
    while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
    n *= f;
  }
  char Of[105], *O1 = Of, *O2 = Of;
  template <class T> inline void print(T n, char ch = '\n') {
    if (n < 0) putchar('-'), n = -n;
    if (n == 0) putchar('0');
    while (n) *(O1++) = (n % 10) ^ 48, n /= 10;
    while (O1 != O2) putchar(*(--O1));
    putchar(ch);
  }
}

using IO :: read;
using IO :: print;

int const MAXN = 1e5 + 15;
int a[MAXN], b[MAXN], c[MAXN];

int MoveL(int L, int R) {
  int now = R, last = R, re = 0;
  for (RI i = R; i > L; --i) {
    while (now >= L && a[now] + (i - now) > b[i]) --now;
    if (now < L || a[now] + (i - now) != b[i])
      puts("-1"), exit(0);
    if (now != last)
      re += i - now, last = now;
  }
  return re;
}
int MoveR(int L, int R) {
  int now = L, last = L, re = 0;
  for (RI i = L; i < R; ++i) {
    while (now <= R && a[now] - (now - i) < b[i]) ++now;
    if (now > R || a[now] - (now - i) != b[i])
      puts("-1"), exit(0);
    if (now != last)
      re += now - i, last = now;
  }
  return re;
}

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, L; read(n), read(L); n += 2;
  for (RI i = 2; i < n; ++i) read(a[i]);
  for (RI i = 2; i < n; ++i) read(b[i]);
  a[1] = b[1] = 0, a[n] = b[n] = L + 1;
  for (RI i = 1; i <= n; ++i)
    if (a[i] > b[i])
      c[i] = 0;
    else if (a[i] < b[i])
      c[i] = 1;
    else
      c[i] = 2;
  for (RI i = 1; i < n; ++i)
    if (c[i] == 1 && c[i + 1] == 0)
      return puts("-1"), 0;
  int ans = 0;
  for (RI i = 1; i <= n; ++i) {
    if (c[i] == 2) continue;
    if (c[i] == 0) {
      int L = i, R = i;
      while (i < n && c[i + 1] == 0) ++i, ++R;
      ans += MoveL(L - 1, R);
    }
    if (c[i] == 1) {
      int L = i, R = i;
      while (i < n && c[i + 1] == 1) ++i, ++R;
      ans += MoveR(L, R + 1);
    }
  }
  print(ans);

  return 0;
}

// created by Daniel yuan
/*
     ________
    /        \
   / /      \ \
  / /        \ \
  \            /
   \  ______  /
    \________/
*/
