#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define N 200100
#define MOD 1000000007 //998244353
#define ll long long
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define eb emplace_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>


int main() {
	ll ans;
	ll n, m, x, k, s, y;
	cin >> n >> m;
	s = 0;
	rep(i, n) {
		cin >> x;
		s = (s + x) % MOD;
	}
	ans = 1;
	x = m + n;
	rep(i, s + n) {
		ans = (ans*x) % MOD;
		x--;
	}
	x = 1;
	rep(i, s + n)x = (x*(i + 1)) % MOD;
	y = MOD - 2;
	k = 1;
	while (y > 0) {
		if (y % 2 == 1) {
			k = (k*x) % MOD;
		}
		x = (x*x) % MOD;
		y /= 2;
	}
	ans = (ans*k) % MOD;
	cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   long long N;
   cin>>N;
   vector<int> v;
   int cnt[3]={0};
   int x=0;
   while(N){
    cnt[(N%10)%3]++;
    x++;
    N=N/10;
   }
   if(cnt[0] || (cnt[1] && cnt[2])){
       int ans=0;
     for(int i=0;i<=cnt[1];i++){
         for(int j=0;j<=cnt[2];j++){
             if((2*j+i)%3==0){
                 ans=max(j+i,ans);
             }
         }
     }
     cout<<cnt[1]+cnt[2]-ans<<"\n";
   }else{
       cout<<-1<<"\n";
   }
   

}