#include using namespace std; long long mod = 1e9+7; long long fact[1234]; long long inv(long long x) { long long ex = mod-2; long long pw = x; long long ans = 1; while(ex) { if(ex%2) ans = (ans*pw)%mod; pw = (pw*pw)%mod; ex /= 2; } return ans; } long long komb(long long a, long long b) { if(a < b || a < 0 || b < 0) return 0; return (fact[a]*(inv(fact[b]*fact[a-b])%mod))%mod; } long long n, k; int bits[1234], mabits[1234]; long long maxans = 0, minans = 0; int main(int argc, char const *argv[]) { for (int i = 0; i < 1234; ++i) { fact[i] = 0; bits[i] = 0; mabits[i] = 0; } cin>>n>>k; fact[0] = 1; for(int i = 1; i <= n; i++) fact[i] = (fact[i-1]*i)%mod; // cout<= 0; i--) { cin>>c; bits[i] = 0; if(c == '1') bits[i] = 1; } int carry = 0; for(int i = 0; i < n; i++) { mabits[i] = (bits[i]+carry+1)%2; carry = (bits[i]+carry+1)/2; } mabits[n] = carry; int k2 = k; // for(int i = n; i >= 0; i--) // cout<= 0; i--) { if(mabits[i]) { maxans = (maxans+komb(i, k2))%mod; k2--; } } k2 = k; for(int i = n; i >= 0; i--) { if(bits[i]) { minans = (minans+komb(i, k2))%mod; k2--; } } int popc = 0; for(int i = 0; i <= n; i++) popc += mabits[i]; if(popc == k) maxans++; cout<<(maxans+mod-minans)%mod<