#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <fstream>
#include <time.h>
#define P(n) cout<<n<<'\n'
#define range(i,a,b) for(auto i=a;i<=b;++i)
#define LL long long
#define ULL unsigned long long
#define elif else if
#define itrange(i,a,b) for(auto i=a;i!=b;++i)
#define rerange(i,a,b) for(auto i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
string word;
LL n;
void init(){
}
void solve(){
while(cin>>word>>n){
LL ans=0, mod=(1LL<<n)-1;
while(!word.empty()){
LL pos=1;
range(i,1,n)if(!word.empty()){
ans=(ans+(word.back()-'0')*pos)%mod;
pos<<=1;
word.pop_back();
}
}
cout<<(ans%mod?"NO":"YES")<<'\n';
}
}
int main() {
init();
solve();
return 0;
}