#include <bits/stdc++.h>
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef long double ld; typedef pair<lint, lint> plint; typedef pair<ld, ld> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;++i)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;--i)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
#define fi first
#define se second
struct fast_ios { fast_ios() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
template<class T> auto add = [](T a, T b) -> T { return a + b; };
template<class T> auto f_max = [](T a, T b) -> T { return max(a, b); };
template<class T> auto f_min = [](T a, T b) -> T { return min(a, b); };
template<class T> using V = vector<T>;
using Vl = V<lint>; using VVl = V<Vl>;
template< typename T > ostream& operator<<(ostream& os, const vector< T >& v) {
    for (int i = 0; i < (int)v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : "");
    return os;
}
template< typename T >istream& operator>>(istream& is, vector< T >& v) {
    for (T& in : v) is >> in;
    return is;
}
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
lint gcd(lint a, lint b) { if (b == 0) return a; else return gcd(b, a % b); }
lint ceil(lint a, lint b) { return (a + b - 1) / b; }
lint digit(lint a) { return (lint)log10(a); }
lint e_dist(plint a, plint b) { return abs(a.fi - b.fi) * abs(a.fi - b.fi) + abs(a.se - b.se) * abs(a.se - b.se); }
lint m_dist(plint a, plint b) { return abs(a.fi - b.fi) + abs(a.se - b.se); }
void Worshall_Floyd(VVl& g) { REP(k, SZ(g)) REP(i, SZ(g)) REP(j, SZ(g)) chmin(g[i][j], g[i][k] + g[k][j]); }
const lint MOD1000000007 = 1000000007, MOD998244353 = 998244353, INF = 2e18;
lint dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 }, dy[8] = { 0, 1, 0, -1, -1, -1, 1, 1 };
bool YN(bool flag) { cout << (flag ? "YES" : "NO"); return flag; } bool yn(bool flag) { cout << (flag ? "Yes" : "No") << endk; return flag; }
struct Edge {
    lint from, to;
    lint cost;
    lint idx;
    Edge() {

    }
    Edge(lint u, lint v, lint c, lint i) {
        cost = c;
        from = u;
        to = v;
        idx = i;
    }
    bool operator<(const Edge& e) const {
        return cost < e.cost;
    }
};
struct WeightedEdge {
    lint to;
    lint cost;
    WeightedEdge(lint v, lint c = 1) {
        to = v;
        cost = c;
    }
    bool operator<(const WeightedEdge& e) const {
        return cost < e.cost;
    }
};
using WeightedGraph = V<V<WeightedEdge>>;
typedef pair<plint, lint> tlint;
typedef pair<plint, plint> qlint;
typedef pair<char, lint> valchar;

lint N, X;
int main() {
    cin >> N >> X;
    Vl arr(N);
    cin >> arr;
    lint minv = INF;
    FOR(m, 1, N + 1) {
        V<VVl> dp(N + 1, VVl(N + 1, Vl(N + 1, -1)));
        dp[0][0][0] = 0;
        REP(i, N) {
            REP(j, N + 1) {
                REP(k, N) {
                    if (dp[i][j][k] == -1) continue;
                    chmax(dp[i + 1][j + 1][(dp[i][j][k] + arr[i]) % (m)], dp[i][j][k] + arr[i]);
                    chmax(dp[i + 1][j][k], dp[i][j][k]);
                }
            }
        }
        REP(j, N + 1) {
            if (dp[N][m][j] == -1) continue;
            if ((X - dp[N][m][j]) % m != 0) continue;
            chmin(minv, (X - dp[N][m][j]) / m);
        }
    }

    cout << minv << endk;
}

#include <bits/stdc++.h>
#define reg register
#define ll long long
#define ull unsigned long long
#define debug(typ...) fprintf(stderr, typ)
using namespace std;
int fastin() {
  reg int x = 0, ch = getchar(), f = 0;
  while(!isdigit(ch)) (ch == '-') && (f = 1), ch = getchar();
  while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
const int MAXN = 110;
int n, ma[MAXN << 1], dp[MAXN][MAXN];
int match(reg int d, reg int u) {
  int fl = 1;
  if(ma[d]) {
    if(ma[d] <= n * 2) fl &= (ma[d] == u);
    else fl &= (ma[d] == n * 2 + 1);
  }
  if(ma[u]) {
    if(ma[u] <= n * 2) fl &= (ma[u] == d);
    else fl &= (ma[u] == n * 2 + 2);
  }
  if(ma[d] == n * 2 + 1 && ma[u] == n * 2 + 2) fl = 0;
  return fl;
}
int dfs(reg int l, reg int r) {
  if(~dp[l][r]) return dp[l][r];
  int len = r - l + 1, fl = 1;
  for(reg int i = l; i <= r && fl; ++i) fl &= match(l + i - 1, l + i + len - 1);
  if(fl) return dp[l][r] = 1;
  for(reg int i = l; i < r && !fl; ++i) fl |= dfs(l, i) && dfs(i + 1, r);
  return dp[l][r] = fl;
}
void work() {
  n = fastin();
  bool flag = 1;
  for(reg int i = 1; i <= n && flag; ++i) {
    int a = fastin(), b = fastin();
    if(a != -1 && b != -1 && a >= b) flag = 0;
    else {
      if(a == -1 && b == -1) continue;
      else if(a == -1) {
        if(ma[b]) flag = 0;
        else ma[b] = n * 2 + 2;
      } else if(b == -1) {
        if(ma[a]) flag = 0;
        else ma[a] = n * 2 + 1;
      } else {
        if(ma[a] || ma[b]) flag = 0;
        else ma[a] = b, ma[b] = a;
      }
    }
  }
  memset(dp, -1, sizeof(dp));
  if(!flag) puts("No");
  else puts(dfs(1, n) ? "Yes" : "No");
}
signed main() {
  int _ = 1;
  // _ = fastin();
  while(_--) {
    work();
  }
  return 0;
}
