#include <algorithm>
#include <cstdio>

constexpr int MAXN = 3000000;
static long long pref[MAXN + 1];
static int idx[MAXN + 1];

class FastInput {
    char buf[1 << 16];
    int pos = 0, len = 0;

    inline int get() {
        if (pos == len) {
            len = std::fread(buf, 1, sizeof(buf), stdin);
            pos = 0;
            if (!len) return EOF;
        }
        return buf[pos++];
    }

public:
    template<class T>
    inline T read() {
        int c = get();
        while (c != EOF && c <= ' ') c = get();
        bool neg = (c == '-');
        if (neg) c = get();

        T x = 0;
        while (c >= '0' && c <= '9') {
            x = x * 10 + (c - '0');
            c = get();
        }
        return neg ? -x : x;
    }
};

int main() {
    FastInput in;
    int n = in.read<int>();
    long long v = in.read<long long>();

    int head = 0, tail = 1, ans = n + 1;
    long long sum = 0;

    for (int r = 1; r <= n; ++r) {
        int x = in.read<int>();
        if (x >= v) {
            std::puts("1");
            return 0;
        }

        sum += x;
        long long limit = sum - v;

        if (pref[head] <= limit) {
            do {
                ++head;
            } while (head < tail && pref[head] <= limit);
            ans = std::min(ans, r - idx[head - 1]);
        }

        while (head < tail && pref[tail - 1] >= sum) --tail;
        pref[tail] = sum;
        idx[tail++] = r;
    }

    std::printf("%d\n", ans <= n ? ans : -1);
}