#include <bits/stdc++.h>
using namespace std;
int mov[4][2] = {
    -1, 0, 0, 1, 1, 0, 0, -1,
};
template <typename T>
struct number_iterator : std::iterator<random_access_iterator_tag, T> {
  T v;
  number_iterator(T _v) : v(_v) {}
  operator T&() { return v; }
  T operator*() const { return v; }
};
template <typename T>
struct number_range {
  T b, e;
  number_range(T b, T e) : b(b), e(e) {}
  number_iterator<T> begin() { return b; }
  number_iterator<T> end() { return e; }
};
template <typename T>
number_range<T> range(T e) {
  return number_range<T>(0, e);
}
template <typename T>
number_range<T> range(T b, T e) {
  return number_range<T>(b, e);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for (int i : range(n)) cin >> v[i];
  reverse((v).begin(), (v).end());
  int total = 1;
  int count = 0;
  while (!v.empty()) {
    int d = v[v.size() - 1];
    if (count + d > m) {
      total++;
      count = 0;
    } else {
      count += d;
      v.pop_back();
    }
  }
  cout << total << endl;
  return 0;
}
