#include <bits/stdc++.h>
 using namespace std;
 set<long long int> adj[3005];
 map<long long int, long long int> mq;
 long long int done[3005][3005];
 int main() {
   ios_base::sync_with_stdio(false);
   long long int n, m, i, ans = 0;
   cin >> n >> m;
   for (i = 0; i < m; i++) {
     long long int x, y;
     cin >> x >> y;
     adj[x].insert(y);
   }
   for (i = 1; i <= n; i++) {
     for (auto it : adj[i]) {
       for (auto it2 : adj[it]) {
         if (mq.find(it2) != mq.end() && it2 != i) {
           ans += mq[it2];
         }
         mq[it2]++;
       }
     }
     mq.clear();
   }
   cout << ans << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
 int main() {
   int a, b, h;
   cin >> a >> b >> h;
   int c = 0;
   while (h != 0) {
     if (c % 2 == 0) {
       h = h - gcd(a, h);
     } else {
       h = h - gcd(b, h);
     }
     c++;
   }
   if (c % 2 == 0) {
     cout << 1 << endl;
   } else
     cout << 0 << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAXN = 100000 + 5;
 const double EPS = 1e-3;
 int n;
 int t[MAXN];
 int g(double q) {
   bool ok = true;
   for (int i = 1; i < n; i++)
     if (fabs(double(t[i] - t[i - 1] * q)) > EPS) ok = false;
   if (ok) return 0;
   ok = true;
   for (int i = 2; i < n; i++)
     if (fabs(double(t[i] - t[i - 1] * q)) > EPS) ok = false;
   if (ok) return 1;
   ok = true;
   int prev = t[0];
   for (int i = 1; i < n; i++)
     if (fabs(double(t[i] - prev * q)) > EPS) {
       if (!ok) return 2;
       ok = false;
     } else
       prev = t[i];
   return 1;
 }
 int f() {
   if (n == 1) return 0;
   double q1 = 0, q2 = 0;
   if (t[0] != 0) q1 = double(t[1]) / t[0];
   if (t[n - 2] != 0) q2 = double(t[n - 1]) / t[n - 2];
   return min(g(q1), g(q2));
 }
 int main() {
   scanf('%d', &n);
   for (int i = 0; i < n; i++) scanf('%d', &t[i]);
   printf('%d
', f());
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAX = 1e6 + 5;
 int a[MAX], run[MAX], ans[MAX];
 char s[MAX];
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int n;
   scanf('%d', &n);
   scanf('%s', s);
   for (int i = 0; i < n; ++i) {
     if (s[i] == '0')
       a[i] = 0;
     else if (s[i] == '1')
       a[i] = 1;
     else
       a[i] = -1;
   }
   vector<pair<int, int>> blocks;
   int it1 = 0, it2 = 0;
   while (it1 != n) {
     while (it2 < n - 1 && a[it1] == a[it2 + 1]) ++it2;
     blocks.emplace_back(it2 - it1 + 1, a[it1]);
     ++it2;
     it1 = it2;
   }
   for (int i = 0; i < (int)blocks.size(); ++i) {
     if (blocks[i].second != -1) continue;
     if (i == 0)
       blocks[i].second = blocks[i + 1].second;
     else if (i == (int)blocks.size() - 1)
       blocks[i].second = blocks[i - 1].second;
     else if (blocks[i - 1].second == blocks[i + 1].second)
       blocks[i].second = blocks[i - 1].second;
   }
   vector<pair<int, int>> compress;
   it1 = 0;
   it2 = 0;
   while (it1 != (int)blocks.size()) {
     int len = blocks[it1].first;
     while (it2 < (int)blocks.size() - 1 &&
            blocks[it1].second == blocks[it2 + 1].second)
       it2++, len += blocks[it2].first;
     compress.emplace_back(len, blocks[it1].second);
     ++it2;
     it1 = it2;
   }
   for (auto block : compress) {
     if (block.second == -1) continue;
     for (int len = 1; len <= block.first; len++) ans[len] += block.first / len;
   }
   int max_size = -1, bef = -2;
   int size = compress.size();
   for (int i = 0; i < size; i++) {
     int len = compress[i].first;
     int type = compress[i].second;
     if (bef != -1 && type != -1) {
       max_size = len;
       if (i != size - 1) max_size += compress[i + 1].first;
       for (int l = 1; l <= max_size; l++) run[l] = len % l;
     } else if (type == -1) {
       for (int l = 1; l <= max_size; l++) {
         if (run[l] + len >= l)
           run[l] += len, ans[l] += run[l] / l, run[l] %= l;
         else
           run[l] = len;
       }
       int add = 0;
       if (i != (int)size - 1) add += compress[i + 1].first;
       if (i != (int)size - 2) add += compress[i + 2].first;
       for (int l = max_size + 1; l <= len + add; ++l) run[l] = (len % l);
       max_size = len + add;
     } else {
       for (int l = 1; l <= max_size; ++l) {
         if (run[l] + (len % l) >= l)
           run[l] += ((len % l) - l), ans[l]++;
         else
           run[l] += (len % l);
       }
     }
     bef = type;
   }
   for (int i = 1; i <= n; ++i) printf('%d ', ans[i]);
   printf('
');
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline int read() {
   int f = 1, x = 0;
   char ch = getchar();
   while (ch < '0' || ch > '9') {
     if (ch == '-') {
       f = -1;
     }
     ch = getchar();
   }
   while (ch >= '0' && ch <= '9') {
     x = x * 10 + ch - '0';
     ch = getchar();
   }
   return x * f;
 }
 const int N = 55;
 struct W {
   int x, y, tx, ty, id;
 } up[N], down[N];
 bool cmp_down(W a, W b) { return a.tx == b.tx ? a.ty < b.ty : a.tx > b.tx; }
 bool cmp_up(W a, W b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }
 vector<pair<int, int> > ans_fr, ans_to;
 bool has[N][N];
 void move_up(int& x, int y) {
   int dx = x;
   has[x][y] = 0;
   has[x - 1][y] = 1;
   ans_fr.push_back(make_pair(dx, y));
   ans_to.push_back(make_pair(dx - 1, y));
   --x;
 }
 void move_down(int& x, int y) {
   int dx = x;
   has[x][y] = 0;
   has[x + 1][y] = 1;
   ans_fr.push_back(make_pair(dx, y));
   ans_to.push_back(make_pair(dx + 1, y));
   ++x;
 }
 void move_left(int x, int& y) {
   int dy = y;
   has[x][y] = 0;
   has[x][y - 1] = 1;
   ans_fr.push_back(make_pair(x, dy));
   ans_to.push_back(make_pair(x, dy - 1));
   --y;
 }
 void move_right(int x, int& y) {
   int dy = y;
   has[x][y] = 0;
   has[x][y + 1] = 1;
   ans_fr.push_back(make_pair(x, dy));
   ans_to.push_back(make_pair(x, dy + 1));
   ++y;
 }
 void move_row(int& x, int& y, int tx, int ty) {
   while (y < ty && has[x][y + 1] == 0) {
     move_right(x, y);
   }
   while (y > ty && has[x][y - 1] == 0) {
     move_left(x, y);
   }
 }
 void move(int& x, int& y, int tx, int ty) {
   while (x < tx) {
     move_down(x, y);
   }
   while (x > tx) {
     move_up(x, y);
   }
   while (y < ty) {
     move_right(x, y);
   }
   while (y > ty) {
     move_left(x, y);
   }
 }
 int check(W a) {
   if (a.x == a.tx) {
     return a.y == a.ty ? 0 : 1;
   } else {
     return a.y == a.ty ? 2 : 3;
   }
 }
 int nx[N], ny[N];
 char mp[N][N];
 int vis[N];
 void write(int n) {
   for (int i = 1; i <= n; i++) {
     cout << mp[i] + 1 << endl;
   }
   puts('----------------------');
 }
 void deal(int n, int m) {
   if (n == 1) {
     puts('0');
   } else {
     if (m == 1) {
       move(up[1].x, up[1].y, up[1].tx, up[1].ty);
     } else {
       if (cmp_up(up[1], up[2]) == 0) {
         swap(up[1], up[2]);
       }
       if (up[1].x == 2) {
         move_up(up[1].x, up[1].y);
         move_up(up[2].x, up[2].y);
       } else if (up[2].x == 2) {
         move_up(up[2].x, up[2].y);
       }
       switch (check(up[1])) {
         case 0:
           break;
         case 1:
           move(up[2].x, up[2].y, 2, 1);
           move_right(up[1].x, up[1].y);
           break;
         case 2:
           move(up[1].x, up[1].y, up[1].tx, up[1].ty);
           break;
         case 3:
           move(up[1].x, up[1].y, up[1].tx, up[1].ty);
           move_left(up[2].x, up[2].y);
           break;
       }
       move(up[2].x, up[2].y, up[2].tx, up[2].ty);
     }
     cout << ans_fr.size() << endl;
     for (int i = 0; i < ans_fr.size(); i++) {
       int xx1 = ans_fr[i].first, xx2 = ans_to[i].first;
       int yy1 = ans_fr[i].second, yy2 = ans_to[i].second;
       printf('%d %d %d %d
', xx1, yy1, xx2, yy2);
     }
   }
 }
 int main() {
   int n = read(), m = read();
   for (int i = 1; i <= n; i++) {
     for (int j = 1; j <= n; j++) {
       mp[i][j] = '.';
     }
   }
   for (int i = 1; i <= m; i++) {
     up[i].id = i;
     nx[i] = up[i].x = read();
     ny[i] = up[i].y = read();
     has[nx[i]][ny[i]] = 1;
     mp[nx[i]][ny[i]] = i + '0';
   }
   for (int i = 1; i <= m; i++) {
     up[i].tx = read();
     up[i].ty = read();
   }
   if (n <= 2) {
     deal(n, m);
     return 0;
   }
   copy(up + 1, up + 1 + m, down + 1);
   sort(up + 1, up + 1 + m, cmp_up);
   int cnt = m;
   while (cnt) {
     for (int i = 1; i <= m; i++) {
       if (vis[i] == 0) {
         int id = up[i].id;
         move_row(nx[id], ny[id], 1, i);
         if (ny[id] == i) {
           vis[i] = 1;
           cnt--;
         }
       }
     }
   }
   for (int i = 1; i <= m; i++) {
     int id = up[i].id;
     while (nx[id] > 1) {
       move_up(nx[id], ny[id]);
     }
   }
   for (int i = 1; i <= m; i++) {
     move_down(nx[i], ny[i]);
     move_down(nx[i], ny[i]);
   }
   sort(down + 1, down + 1 + m, cmp_down);
   for (int i = 1; i <= m; i++) {
     int id = down[i].id;
     move_up(nx[id], ny[id]);
     move_row(nx[id], ny[id], 1, i);
     move_up(nx[id], ny[id]);
   }
   for (int i = 1; i <= m; i++) {
     int id = down[i].id;
     while (nx[id] < down[i].tx) {
       move_down(nx[id], ny[id]);
     }
   }
   cnt = m;
   while (cnt) {
     for (int i = 1; i <= m; i++) {
       if (vis[i] == 1) {
         int id = down[i].id;
         move_row(nx[id], ny[id], nx[id], down[i].ty);
         if (ny[id] == down[i].ty) {
           vis[i] = 2;
           cnt--;
         }
       }
     }
   }
   assert(ans_fr.size() == ans_to.size());
   assert(ans_fr.size() <= 10800);
   cout << ans_fr.size() << endl;
   for (int i = 0; i < ans_fr.size(); i++) {
     int xx1 = ans_fr[i].first, xx2 = ans_to[i].first;
     int yy1 = ans_fr[i].second, yy2 = ans_to[i].second;
     printf('%d %d %d %d
', xx1, yy1, xx2, yy2);
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, m;
   cin >> n >> m;
   int a[m], b[m];
   int ndup = n;
   for (int i = 0; i < m; i++) {
     cin >> a[i];
     b[i] = a[i];
   }
   sort(a, a + m);
   sort(b, b + m, greater<int>());
   int mn = 0, mx = 0;
   for (int i = 0; i < m; i++) {
     while (a[i] > 0 && n > 0) {
       mn += a[i];
       a[i]--;
       n--;
     }
   }
   while (ndup > 0) {
     mx += b[0];
     b[0]--;
     ndup--;
     sort(b, b + m, greater<int>());
   }
   cout << mx << ' ' << mn;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, t;
   cin >> t;
   while (t--) {
     cin >> n;
     cout << (n + 1) / 2 << endl;
   }
 }


//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE...
 #include <bits/stdc++.h>
 using namespace std;
 #define FAST_FURIER ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 #define pb push_back
 #define mk make_pair
 #define rep(i,a,N) for(ll i=a;i<N;i++)
 #define rrep(i,a,N) for(ll i=a;i>N;i--)
 typedef long long ll;
 #define M 1000000007
 bool comp(int x,int y)
 {
     return x > y;
 }

 /*..............................code starts here........................*/
 // C is first won in M

 int main() {
     FAST_FURIER;
     int tt=1;
     cin >> tt;
     ll m,d,k;
    //ll a,b,c;
     while(tt--)
     {
         cin >> d >> k;
         ll x = 0,y = 0;
         int f = 0;
         while(true){
             ll d1 = pow(x+k,2)+pow(y,2), d2 = pow(x,2)+pow(y+k,2);
             f = abs(f-1);
             if(d1 < d2 and d1 <= d*d){
                 x += k;
             }
             else if(d2 <= d1 and d2 <= d*d) y += k;
             else break;
         }
         if(f) cout << 'Utkarsh';
         else cout << 'Ashish';
         cout << endl;

     }
 }

 // Author : shivam_123

 // g++ -std=c++17


#include <bits/stdc++.h>
 using namespace std;
 long long a, b, c, e[200000], mix, l, r, o, d[200000];
 vector<long long> v[100000], v1;
 set<long long> st;
 map<long long, long long> mp, mp1;
 string s;
 pair<int, int> p[100000], p1[100000];
 char ch[10];
 deque<char> dq;
 int main() {
   cin >> a;
   for (int i = 0; i < a / 4; i++)
     if ((a - 2 * (i + 1)) % 2 == 0) c++;
   if (a % 4 == 0) {
     cout << c - 1;
   } else
     cout << c;
 }


#include <bits/stdc++.h>
 using namespace std;
 char s[5000005];
 int len[1000005];
 int idx[1000005];
 int sum[1000005];
 int sz = 0;
 int dp[1000005][20];
 int p[1000005];
 int main() {
   int n, r, c;
   scanf('%d%d%d', &n, &r, &c);
   gets(s);
   gets(s);
   int cnt = 0, slen = 0;
   for (int i = 0; s[i]; i++, slen++) {
     if (s[i] == ' ' && cnt != 0) {
       len[sz] = cnt;
       idx[sz++] = i - cnt;
       cnt = 0;
     } else
       cnt++;
   }
   if (cnt > 0) {
     len[sz] = cnt;
     idx[sz++] = slen - cnt;
     cnt = 0;
   }
   sum[0] = len[0];
   for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + 1 + len[i];
   for (int i = n - 1; i >= 0; i--) {
     int id = upper_bound(sum, sum + n, (i > 0 ? sum[i - 1] + 1 : 0) + c) - sum;
     if (id > n) id = n;
     dp[i][0] = id - i;
   }
   for (int j = 2, t = 1; j <= r; j *= 2, t++) {
     for (int i = n - 1; i >= 0; i--)
       dp[i][t] = dp[i][t - 1] + dp[i + dp[i][t - 1]][t - 1];
   }
   int maid = -1, ma = 0;
   for (int i = 0; i < n; i++) {
     int idx = i, rr = r, cur = 0;
     for (int j = 20; j >= 0; j--) {
       if (rr >= (1 << j)) {
         rr -= (1 << j);
         cur += dp[idx][j];
         idx += dp[idx][j];
       }
     }
     if (cur > ma) maid = i, ma = cur;
   }
   int cn = 1, cs = dp[maid][0];
   for (int i = maid; i < maid + ma; i++) {
     s[idx[i] + len[i]] = 0;
     if (cn < cs) {
       printf('%s ', s + idx[i]);
       cn++;
     } else {
       printf('%s
', s + idx[i]);
       cs = dp[i + 1][0];
       cn = 1;
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 char change(char curranswer) {
   if (curranswer == 'z')
     curranswer = 'A';
   else if (curranswer == 'Z')
     curranswer = '0';
   else if (curranswer == '9')
     ;
   else
     curranswer++;
   return curranswer;
 }
 int main() {
   long long i, j, t;
   cin >> t;
   while (t--) {
     long long r, c, k;
     long long rice = 0;
     char a[100][100];
     cin >> r >> c >> k;
     for (i = 0; i < r; i++) {
       for (j = 0; j < c; j++) {
         cin >> a[i][j];
         if (a[i][j] == 'R') rice++;
       }
     }
     long long ans = rice / k;
     long long maxx = rice - k * ans;
     long long minn = k - maxx;
     char curranswer = 'a';
     long long currcount = 0;
     bool flag = true;
     for (i = 0; i < r; i++) {
       for (flag ? (j = 0) : (j = c - 1); flag ? (j < c) : j >= 0;
            flag ? j++ : j--) {
         bool local = false;
         if (a[i][j] == 'R') local = true;
         a[i][j] = curranswer;
         if (local) {
           currcount++;
           if (maxx > 0) {
             if (currcount == ans + 1) {
               maxx--;
               currcount = 0;
               curranswer = change(curranswer);
             }
           } else if (minn > 0) {
             if (currcount == ans) {
               minn--;
               currcount = 0;
               if (minn) curranswer = change(curranswer);
             }
           }
         }
       }
       flag = !flag;
     }
     for (i = 0; i < r; i++) {
       for (j = 0; j < c; j++) cout << a[i][j];
       cout << endl;
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 long long gcd(long long x, long long y) {
   if (y == 0)
     return x;
   else
     return gcd(y, x % y);
 }
 long long expo(long long n, long long m) {
   long long r = 1;
   while (m > 0) {
     if (m % 2) r = (r * n) % 1000000009;
     n = (n * n) % 1000000009;
     m = m / 2;
   }
   return r % 1000000009;
 }
 long long lx = 0, ly = 0;
 bool check(long long x, long long y) {}
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   ;
   long long a, b;
   cin >> a >> b;
   string s;
   cin >> s;
   long long p = 0, q = 0;
   if (a == 0 && b == 0) {
     cout << 'Yes';
     return 0;
   }
   for (long long i = 0; i < s.size(); i++) {
     if (s[i] == 'U') {
       ly++;
     } else if (s[i] == 'D')
       ly--;
     else if (s[i] == 'L')
       lx--;
     else
       lx++;
     if (lx == a && ly == b) {
       cout << 'Yes';
       return 0;
     }
   }
   if (lx == 0 && ly == 0) {
     cout << 'No';
     return 0;
   }
   for (long long i = 0; i < s.size(); i++) {
     if (s[i] == 'U') {
       q++;
     } else if (s[i] == 'D')
       q--;
     else if (s[i] == 'L')
       p--;
     else
       p++;
     long long x = a - p, y = b - q, X = lx, Y = ly;
     if (lx == 0) {
       if (ly > 0 && y > 0 && x == 0 && y % ly == 0) {
         cout << 'Yes';
         return 0;
       } else if (ly < 0 && y < 0 && x == 0) {
         ly = -1 * ly, y = -1 * y;
         if (y % ly == 0) {
           cout << 'Yes';
           return 0;
         }
       }
     } else if (ly == 0) {
       if (lx > 0 && x > 0 && y == 0 && x % lx == 0) {
         cout << 'Yes';
         return 0;
       } else if (lx < 0 && x < 0 && y == 0) {
         lx = -1 * lx, x = -1 * x;
         if (x % lx == 0) {
           cout << 'Yes';
           return 0;
         }
       }
     } else {
       if (lx > 0 && x > 0) {
         if (ly > 0 && y > 0) {
           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) {
             cout << 'Yes';
             return 0;
           }
         } else if (ly < 0 && y < 0) {
           ly = -1 * ly, y = -1 * y;
           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) {
             cout << 'Yes';
             return 0;
           }
         }
       } else if (lx < 0 && x < 0) {
         lx = -1 * lx, x = -1 * x;
         if (ly > 0 && y > 0) {
           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) {
             cout << 'Yes';
             return 0;
           }
         } else if (ly < 0 && y < 0) {
           ly = -1 * ly, y = -1 * y;
           if (x / lx == y / ly && x % lx == 0 && y % ly == 0) {
             cout << 'Yes';
             return 0;
           }
         }
       }
     }
     lx = X, ly = Y;
   }
   cout << 'No';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = int(3e5), mod = int(1e9) + 7;
 int n;
 int a[N], c[N];
 long long t[N];
 long long x[N], pref[N];
 long double p[N];
 long long suf[N];
 void upd(int v, int val) {
   v += n - 1;
   t[v] += val;
   c[v]++;
   while (v > 1) {
     v >>= 1;
     t[v] = t[v + v] + t[v + v + 1];
     c[v] = c[v + v] + c[v + v + 1];
   }
 }
 long long get(int l, int r) {
   l += n - 1;
   r += n - 1;
   long long res = 0;
   while (l <= r) {
     if (l & 1) res += t[l];
     if (!(r & 1)) res += t[r];
     l = (l + 1) >> 1;
     r = (r - 1) >> 1;
   }
   return res;
 }
 int cnt(int l, int r) {
   l += n - 1;
   r += n - 1;
   int res = 0;
   while (l <= r) {
     if (l & 1) res += c[l];
     if (!(r & 1)) res += c[r];
     l = (l + 1) >> 1;
     r = (r - 1) >> 1;
   }
   return res;
 }
 int main() {
   scanf('%d', &n);
   for (int i = 1; i <= n; i++) {
     scanf('%d', &a[i]);
   }
   long long all = 1ll * n * (n + 1) / 2;
   long double res = 0;
   for (int i = 1; i <= n; i++) {
     long long cur = get(1, a[i] - 1);
     long double p = (cur + 0.0) * (n - i + 1) / all;
     res += p * 0.5;
     cur = get(a[i] + 1, n);
     p = (cur + 0.0) * (n - i + 1) / all;
     res += cnt(a[i] + 1, n);
     res -= p * 0.5;
     upd(a[i], i);
   }
   printf('%.12lf', double(res));
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long a, b;
   cin >> a >> b;
   long long ans = 0;
   while (true) {
     long long x = max(a, b);
     long long y = min(a, b);
     if (x == 0 || y == 0) break;
     long long n = x / y;
     ans += n;
     x -= n * y;
     a = x;
     b = y;
   }
   cout << ans;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int x, test;
   cin >> test;
   while (test--) {
     int n, c0, c1, h;
     string s;
     cin >> n >> c0 >> c1 >> h >> s;
     int cnt0 = 0, cnt1 = 0;
     for (auto &z : s) {
       cnt0 += z == '0';
       cnt1 += z == '1';
     }
     int cost = (cnt0 * c0) + (cnt1 * c1);
     int cost0 = (c0 * n) + (cnt1 * h);
     int cost1 = (c1 * n) + (cnt0 * h);
     cout << min({cost, cost0, cost1}) << '
';
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int inf = int(1e9) + 123;
 int main() {
   int n, v;
   cin >> n >> v;
   vector<int> a;
   for (int i = 1; i <= n; i++) {
     int x;
     cin >> x;
     a.push_back(x);
   }
   sort(a.begin(), a.end());
   int sum = 0;
   for (int i = 0; i < a.size() - 1; i++) {
     sum += a[i];
   }
   if (sum <= v) {
     cout << 'YES';
   } else {
     cout << 'NO';
   }
   return 0;
 }