#include <iostream>
#include <vector>
#include <assert.h>

const int SizeOfCommand = 30;
enum {
    removeMin,
    insert,
    getMin
};

class Heap {
    void SiftUp (int i);
    void SiftDown (int i);
public:
    void ExtractMin ();
    void Insert (int key);
    int GetMin ();
    void Print ();
    std::vector<int> data;

    static const int Empty = -1000000027;
};

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap);

int main () {
    FILE* f_in = stdin; //fopen ("input.txt", "r");
    Heap heap;
    int n = 0;
    int m = 0;
    fscanf  (f_in, "%d", &n);

    std::vector<int> command;
    std::vector<int> args;

    char *temp_str = new char[SizeOfCommand];
    int argument = 0;

    for (int i = 0; i < n; ++i) {
        fscanf  (f_in, "%s", temp_str);
        switch (*temp_str) {
            case 'r':
                if (heap.data.size() != 0) {
                    heap.ExtractMin ();
                } else {
                    command.push_back (insert);
                    args.push_back (0);
                    ++m;
                }
                command.push_back (removeMin);
                break;
            case 'i':
                command.push_back (insert);
                fscanf  (f_in, "%d", &argument);
                heap.Insert (argument);
                args.push_back (argument);
                break;
            case 'g':
                fscanf  (f_in, "%d", &argument);
                m += NewCommands (argument, command, args, heap);
                break;
        }
    }
    m += n;
    printf ("%d\n", m);
    int j = 0;
    for (int i = 0; i < m; ++i) {
        switch (command[i]) {
            case insert:
                printf ("insert %d\n", args[j]);
                ++j;
                break;
            case removeMin:
                printf ("removeMin\n");
                break;
            case getMin:
                printf ("getMin %d\n", args[j]);
                ++j;
                break;
        }
    }
    delete[] temp_str;
    return 0;
}

int NewCommands (int argument, std::vector<int> &commands, std::vector<int> &args, Heap& heap) {
    int col = 0;
    int h_min = heap.GetMin ();
    while (h_min != heap.Empty && h_min < argument) {
        heap.ExtractMin ();
        commands.push_back (removeMin);
        col++;
        h_min = heap.GetMin ();
    }

    if (h_min != argument) {
        heap.Insert (argument);
        commands.push_back (insert);
        args.push_back (argument);
        col++;
    }

    commands.push_back (getMin);
    args.push_back (argument);
    return col;
}

void swap (int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void Heap::SiftUp (int i) {
    while (i > 0 && data[(i - 1) / 2] > data[i]) {
        swap (data[(i - 1) / 2], data[i]);
        i = (i - 1) / 2;
    }
}

void Heap::SiftDown (int i) {
//    for (int c : data)
//        std::cout << c << " " ;
//    printf ("\n");
//    int col = 12;
    while (i < data.size () / 2) {
        int left = 2 * i + 1;
        int right = 2 * (i + 1);
//        printf ("left = %d, right = %d \n", left, right);
//        col--;
//        if (col == 0) break;
        int s;
        if (data[i] > data[left] || data[i] > data[right]) {

            if (data[left] < data[right]) s = left;
            else s = right;
//            printf ("i = %d, s = %d  data[i] = %d, data[s] =  %d \n", i, s, data[i], data[s]);
            swap (data[i], data[s]);
            i = s;
        } else break;
    }
}

void Heap::Print () {
    for (int c : data)
        std::cout << c << " ";

}

int Heap::GetMin () {
    if (data.size () == 0) {
        return Empty;
    }
    return data[0];
}

void Heap::ExtractMin () {
    assert (data.size () != 0);
    swap (data[0], data[data.size () - 1]);
    data.pop_back ();
    SiftDown (0);
}

void Heap::Insert (int key) {
    data.push_back (key);
    SiftUp (data.size () - 1);
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 10000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){cin>>m;}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            if(q.empty()){q.push(1); b[j]='i'; a[j++]=1; mp[1]++;}
            mp[q.top()]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(q.empty()){q.push(1); b[j]='i'; a[j++]=1; mp[1]++;
            b[j]='g'; a[j++]=1;

          }
             else{
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
                q.push(m*-1); b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')cout<<"insert "; else if(b[i]=='r')cout<<"removeMin"<<endl; else cout<<"getMin ";
        if(b[i]!='r')cout<<a[i]<<endl;
     }
}
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 10000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){cin>>m;}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            if(q.empty()){q.push(1); b[j]='i'; a[j++]=1; mp[1]++;}
            mp[q.top()]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
                q.push(m*-1); b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')cout<<"insert "; else if(b[i]=='r')cout<<"removeMin"<<endl; else cout<<"getMin ";
        if(b[i]!='r')cout<<a[i]<<endl;
     }
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 1000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){cin>>m;}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            mp[q.top()]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
                q.push(m*-1); b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')cout<<"insert "; else if(b[i]=='r')cout<<"removeMin"<<endl; else cout<<"getMin ";
        if(b[i]!='r')cout<<a[i]<<endl;
     }
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 1000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){cin>>m;}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            if(q.empty()){q.push(0); b[j]='i'; a[j++]=0; mp[0]++;}
            mp[q.top()*-1]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()*-1]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
               b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')cout<<"insert "; else if(b[i]=='r')cout<<"removeMin"<<endl; else cout<<"getMin ";
        if(b[i]!='r')cout<<a[i]<<endl;
     }
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 1000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){cin>>m;}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            if(q.empty()){q.push(1); b[j]='i'; a[j++]=1; mp[1]++;}
            mp[q.top()]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
                q.push(m*-1); b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')cout<<"insert "; else if(b[i]=='r')cout<<"removeMin"<<endl; else cout<<"getMin ";
        if(b[i]!='r')cout<<a[i]<<endl;
     }
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 1000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){cin>>m;}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            if(q.empty()){q.push(0); b[j]='i'; a[j++]=0; mp[0]++;}
            mp[q.top()*-1]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()*-1]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
                q.push(m*-1); b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')cout<<"insert "; else if(b[i]=='r')cout<<"removeMin"<<endl; else cout<<"getMin ";
        if(b[i]!='r')cout<<a[i]<<endl;
     }
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 1000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){scanf("%d",&m);}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            if(q.empty()){q.push(0); b[j]='i'; a[j++]=0; mp[0]++;}
            mp[q.top()*-1]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()*-1]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
               b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')printf("%s","insert "); else if(b[i]=='r')printf("%s\n","removeMin"); else printf("%s","getMin ");
        if(b[i]!='r')printf("%d\n",a[i]);
     }
}


#include <bits/stdc++.h>
using namespace std;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define ll long long
const int N = 1000000;
priority_queue<int>q;
map<int,int>mp;
int a[N];
char b[N];
char t[50];
 int main() {
     int n; string s; int m;cin>>n; int j=0;
     for(int i=0;i<n;i++){
         scanf("%s",t); s=t;
        if(s!="removeMin"){cin>>m;}
        if(s=="insert"){
            q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;
        }
        else if(s=="removeMin"){
            if(q.empty()){q.push(1*-1); b[j]='i'; a[j++]=1; mp[1]++;}
            mp[q.top()*-1]--; q.pop(); b[j]='r'; a[j++]=0;
        }
        else if(s=="getMin"){
            if(mp[m]==0){q.push(m*-1); b[j]='i'; a[j++]=m; mp[m]++;}
            if(m==q.top()*-1){b[j]='g'; a[j++]=m;}
            else{
                while(q.top()*-1!=m){
                  mp[q.top()*-1]--;
                  q.pop();    b[j]='r'; a[j++]=0;
                }
                q.push(m*-1); b[j]='g'; a[j++]=m; mp[m]++;
            }

        }

     } cout<<j<<endl;
     for(int i=0;i<j;i++){
        if(b[i]=='i')cout<<"insert "; else if(b[i]=='r')cout<<"removeMin"<<endl; else cout<<"getMin ";
        if(b[i]!='r')cout<<a[i]<<endl;
     }
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;

class Solution {
public:
	vector<string> Strs{ "insert ", "getMin ", "removeMin\n" };
	void solve() {
		int n;
		scanf("%d", &n);
		priority_queue<int, vector<int>, greater<int>> pq;
		vector<pair<int, int>> res;
		char op[10];
		int x;
		for (size_t i = 0; i < n; i++) {
			scanf("%s", op);
			if (op[0] == 'i') {
				scanf("%d", &x);
				pq.push(x);
				// insert x
				res.push_back({ 0, x });
			}
			else if (op[0] == 'r') {
				if (pq.empty()) {
					res.push_back({ 0, 0 });
				}
				else {
					pq.pop();
				}
				// removeMin
				res.push_back({ 2,0 });
			}
			else {
				scanf("%d", &x);
				while (!pq.empty() && pq.top() < x) {
					int minv = pq.top();
					pq.pop();
					// removeMin
					res.push_back({ 2,0 });
				}
				if (pq.empty() || pq.top() > x) {
					pq.push(x);
					// insert x
					res.push_back({ 0, x });
				}
				// getMin x
				res.push_back({ 1, x });
			}
		}
		printf("%d\n", res.size());
		for (auto& p : res) {
			printf("%s", Strs[p.first].c_str());
			if (p.first != 2) printf("%d\n", p.second);
		}
	}
};

int main() {
	auto sln = new Solution();
	sln->solve();
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;

class Solution {
   public:
    void solve() {
        int n;
        scanf("%d", &n);
        priority_queue<int, vector<int>, greater<int>> pq;
        vector<string> res;
        char op[10];
        int x;
        for (size_t i = 0; i < n; i++) {
            scanf("%s", op);
            if (op[0] == 'i') {
                scanf("%d", &x);
                pq.push(x);
                // insert x
                res.push_back(string("insert ") + to_string(x));
            } else if (op[0] == 'r') {
                if (pq.empty()) {
                    res.push_back("insert 0");
                } else {
                    pq.pop();
                }
                // removeMin
                res.push_back("removeMin");
            } else {
                scanf("%d", &x);
                while (!pq.empty() && pq.top() < x) {
                    int minv = pq.top();
                    pq.pop();
                    // removeMin
                    res.push_back("removeMin");
                }
                if (pq.empty() || pq.top() > x) {
                    pq.push(x);
                    // insert x
                    res.push_back(string("insert ") + to_string(x));
                    // getMin x
                    res.push_back(string("getMin ") + to_string(x));
                }
            }
        }
        cout << res.size() << endl;
        for (auto& s : res) {
            cout << s << endl;
        }
    }
};

int main() {
    auto sln = new Solution();
    sln->solve();
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;

class Solution {
public:
	vector<string> Strs{ "insert ", "getMin ", "removeMin" };
	void solve() {
		int n;
		scanf("%d", &n);
		priority_queue<int, vector<int>, greater<int>> pq;
		vector<pair<int, int>> res;
		char op[10];
		int x;
		for (size_t i = 0; i < n; i++) {
			scanf("%s", op);
			if (op[0] == 'i') {
				scanf("%d", &x);
				pq.push(x);
				// insert x
				res.push_back({ 0, x });
			}
			else if (op[0] == 'r') {
				if (pq.empty()) {
					res.push_back({ 0, 0 });
				}
				else {
					pq.pop();
				}
				// removeMin
				res.push_back({ 2,0 });
			}
			else {
				scanf("%d", &x);
				while (!pq.empty() && pq.top() < x) {
					int minv = pq.top();
					pq.pop();
					// removeMin
					res.push_back({ 2,0 });
				}
				if (pq.empty() || pq.top() > x) {
					pq.push(x);
					// insert x
					res.push_back({ 0, x });
				}
				// getMin x
				res.push_back({ 1, x });
			}
		}
		cout << res.size() << endl;
		for (auto& p : res) {
			printf("%s", Strs[p.first].c_str());
			if (p.first != 2) printf("%d", p.second);
			cout << endl;
		}
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	auto sln = new Solution();
	sln->solve();
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;

class Solution {
public:
	vector<string> Strs{ "insert ", "getMin ", "removeMin" };
	void solve() {
		int n;
		scanf("%d", &n);
		priority_queue<int, vector<int>, greater<int>> pq;
		vector<pair<int, int>> res;
		char op[10];
		int x;
		for (size_t i = 0; i < n; i++) {
			scanf("%s", op);
			if (op[0] == 'i') {
				scanf("%d", &x);
				pq.push(x);
				// insert x
				res.push_back({ 0, x });
			}
			else if (op[0] == 'r') {
				if (pq.empty()) {
					res.push_back({ 0, 0 });
				}
				else {
					pq.pop();
				}
				// removeMin
				res.push_back({ 2,0 });
			}
			else {
				scanf("%d", &x);
				while (!pq.empty() && pq.top() < x) {
					int minv = pq.top();
					pq.pop();
					// removeMin
					res.push_back({ 2,0 });
				}
				if (pq.empty() || pq.top() > x) {
					pq.push(x);
					// insert x
					res.push_back({ 0, x });
				}
				// getMin x
				res.push_back({ 1, x });
			}
		}
		cout << res.size() << endl;
		for (auto& p : res) {
			cout << Strs[p.first];
			if (p.first != 2) cout << p.second;
			cout << endl;
		}
	}
};

int main() {
	auto sln = new Solution();
	sln->solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;

int main()
{
    string a,b;
    while ( cin >> a >> b )
    {
        int asum = 0;
        int bsum = 0;
        /*for ( int i = 0 ; i < a.size() ; i++ )
        {
            asum += a[i]-'0';
        }
        for ( int i = 0 ; i < b.size() ; i++ )
        {
            bsum += b[i]-'0';
        }*/
        int x=0;
        string h;
        bool f = false;
        while ( true )
        {
            int sum = 0;
            for ( int i = 0 ; i < a.size() ; i++ )
            {
                sum+= a[i]-'0';
            }
            if ( b[x] == '1' && sum%2 == 1 )
            {
                a+= '1';
                x++;
            }
            else
            while ( true )
            if ( b[x] == '0' && sum%2 == 0 )
            {
                a+= '0';
                x++;
            }
            else
                break;
            if ( a == b )
            {
                f = true;
                break;
            }
            if ( a.size() == 0 )
                break;
            a.erase(0,1);
        }
        if ( f )
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
int ones(string a)
{
    int sum=0;
    for ( int i = 0 ; i < a.size() ; i++ )
    {
        sum+= a[i]-'0';
    }
    return sum;
}
int main()
{
    string a,b;
    while ( cin >> a >> b )
    {
        int asum = 0;
        int bsum = 0;
        /*for ( int i = 0 ; i < a.size() ; i++ )
        {
            asum += a[i]-'0';
        }
        for ( int i = 0 ; i < b.size() ; i++ )
        {
            bsum += b[i]-'0';
        }*/
        int x=0;
        //string h;
        bool f = false;
        int d = a.size()-1;
        bool y = true;
        if ( a.size() > b.size() )
        for ( int j = b.size()-1 ; j >= 0 ; j-- )
        {
            if ( b[j] != a[d--] )
            {
                y = false;
                break;
            }
        }
        if ( y ) f = true;

        if ( !f )
        for ( int j = 0 ; j < b.size() ; j++ )
        {
            int sum = ones(a);
            if ( b[j] == '0' && sum%2==0 )
            {
                a+= '0';
                continue;
            }
            else if ( b[j] == '0' && sum%2!=0 )
            {
                for ( int i = 0 ; i < a.size() ; i++ )
                {
                    if ( a[i] == '0' )
                    {
                        a.erase(0,1);
                        i--;
                    }
                    else
                    {
                        a.erase(0,1);
                        break;
                    }
                }
                if ( ones(a)%2==0 )
                    a+= '0';
                continue;
            }
            if ( b[j] == '1' && sum%2==1 )
            {
                a+= '1';
                continue;
            }
            else if ( b[j] == '1' && sum%2!=1 )
            {
                for ( int i = 0 ; i < a.size() ; i++ )
                {
                    if ( a[i] == '0' )
                    {
                        a.erase(0,1);
                        i--;
                    }
                    else
                    {
                        a.erase(0,1);
                        break;
                    }
                }
                if ( ones(a)%2==1 )
                    a+= '1';
                continue;
            }
        }
        d = a.size()-1;
        bool er = true;
        if ( a.size() > b.size() )
        for ( int j = b.size()-1 ; j >= 0 ; j-- )
        {
            if ( b[j] != a[d--] )
            {
                er = false;
                break;
            }
        }
        if ( er ) f = true;
        if ( a == b || f )
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>

using namespace std;

char t1[1005], t2[1005];

int main ()
{
    int a,b,j1=0,j2=0,akt;

    scanf ("%s\n%s", t1, t2);

    for (a=0; t1[a]; a++)
        if (t1[a]=='1')
           j1++;

    j1+=j1%2;

    for (a=0; t2[a]; a++)
        if (t2[a]=='1')
           j2++;

    if (j2<=j1)
       printf ("YES\n");
    else
         printf ("NO\n");

    getchar();
    getchar();
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>

using namespace std;

char t1[1005], t2[1005];

int main ()
{
    int a,b,j1=0,j2=0,akt;

    scanf ("%s\n%s", t1, t2);

    for (a=0; t1[a]; a++);

    for (a--; a>=0 && t1[a]=='1'; a--)
        j1++;

    if (j1%2)
       j1++;

    for (a=0; t2[a]; a++)
        if (t2[a]=='1')
           j2++;

    if (j2<=j1)
       printf ("YES\n");
    else
         printf ("NO\n");

    getchar();
    getchar();
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>

using namespace std;

char t1[1005], t2[1005];

int main ()
{
    int a,b,j1=0,j2=0;

    scanf ("%s\n%s", t1, t2);

    for (a=0; t1[a]; a++)
        if (t1[a]=='1')
           j1++;

    for (a=0; t2[a]; a++)
        if (t2[a]=='1')
           j2++;

    if (j2<=j1)
       printf ("YES\n");
    else
         printf ("NO\n");

    getchar();
    getchar();
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>

using namespace std;

char t1[1005], t2[1005];

int main ()
{
    int a,b,j1=0,j2=0,akt;

    scanf ("%s\n%s", t1, t2);

    for (a=0; t1[a]; a++)
    {
        if (t1[a]=='1')
        {
                       akt=1;

                       for (a++; t1[a] && t1[a]=='1'; a++)
                           akt++;

                       a--;
                       j1=max(j1,akt);
        }
    }

    for (a=0; t2[a]; a++)
        if (t2[a]=='1')
           j2++;

    if (j2<=j1 || (j1==1 && j2==2))
       printf ("YES\n");
    else
         printf ("NO\n");

    getchar();
    getchar();
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>

using namespace std;

char t1[1005], t2[1005];

int main ()
{
    int a,b,j1=0,j2=0;

    scanf ("%s\n%s", t1, t2);

    for (a=0; t1[a]; a++)
        if (t1[a]=='1')
           j1++;

    for (a=0; t2[a]; a++)
        if (t2[a]=='1')
           j2++;

    if (j2<=j1 || (j1==1 && j2==2))
       printf ("YES\n");
    else
         printf ("NO\n");

    getchar();
    getchar();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;

#define MAX 10000

bool find(char *a, char *b, int sa, int sb, int pos, int size, int parity) {
    int j = 0;
    for (int i = size; i < sb; ++i) {
        int needed = b[i] - '0';

        while (parity != needed) {
            if (j == pos)
                return false;

            if (a[j] == '1')
                parity = 1 - parity;
            j++;
        }
    }
    return true;
}

int main(int argc, char *argv[]) {
    char a[MAX], b[MAX];
    cin >> a >> b;
    size_t sa = strlen(a);
    size_t sb = strlen(b);

    int parity = 0;
    for (int i = 0; i < sa; ++i)
        if (a[i] == '1')
            parity = 1 - parity;

    int pos = sa;
    int size = 0;
    bool correct = false;
    for (int i = 0; i < sa; ++i) {
        int k = 0;
        while (k < sb && i+k < sa && a[i+k] == b[k])
            k++;
        if (i+k == sa) {
            pos = i;
            size = k;
            //cerr << pos << ' ' << size << endl;
            correct |= find(a, b, sa, sb, pos, size, parity);
            if (correct) break;
        }
    }

    if (correct)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return EXIT_SUCCESS;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;

#define MAX 10000

int main(int argc, char *argv[]) {
    char a[MAX], b[MAX];
    cin >> a >> b;
    size_t sa = strlen(a);
    size_t sb = strlen(b);

    int parity = 0;
    for (int i = 0; i < sa; ++i)
        if (a[i] == '1')
            parity = 1 - parity;

    int pos = sa;
    int size = 0;
    for (int i = 0; i < sa; ++i) {
        int k = 0;
        while (k < sb && i+k < sa && a[i+k] == b[k])
            k++;
        if (i+k == sa) {
            pos = i;
            size = k;
            break;
        }
    }

    cerr << pos << ' ' << size << endl;

    bool correct = true;
    int j = 0;
    for (int i = size; i < sb; ++i) {
        int needed = b[i] - '0';

        while (parity != needed) {
            if (j == pos) {
                correct = false;
                break;
            }
            if (a[j] == '1')
                parity = 1 - parity;
            j++;
        }

        if (!correct)
            break;

    }

    if (correct)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return EXIT_SUCCESS;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;

#define MAX 10000

bool find(char *a, char *b, int sa, int sb, int pos, int size, int parity) {
    int j = 0;
    for (int i = size; i < sb; ++i) {
        int needed = b[i] - '0';

        while (parity != needed) {
            if (j == pos)
                return false;
            if (a[j] == '1')
                parity = 1 - parity;
            j++;
        }
    }
    return true;
}

int main(int argc, char *argv[]) {
    char a[MAX], b[MAX];
    cin >> a >> b;
    size_t sa = strlen(a);
    size_t sb = strlen(b);

    int parity = 0;
    for (int i = 0; i < sa; ++i)
        if (a[i] == '1')
            parity = 1 - parity;

    int pos = sa;
    int size = 0;
    bool correct = false;
    for (int i = 0; i < sa; ++i) {
        int k = 0;
        while (k < sb && i+k < sa && a[i+k] == b[k])
            k++;
        if (i+k == sa) {
            pos = i;
            size = k;
            //cerr << pos << ' ' << size << endl;
            correct |= find(a, b, sa, sb, pos, size, parity);
            if (correct) break;
        }
    }

    correct |= find(a, b, sa, sb, sa, 0, parity);

    if (correct)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return EXIT_SUCCESS;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;

#define MAX 10000

bool find(char *a, char *b, int sa, int sb, int pos, int size, int parity) {
    int j = 0;
    for (int i = size; i < sb; ++i) {
        int needed = b[i] - '0';

        while (parity != needed) {
            if (j == pos)
                return false;
            if (a[j] == '1')
                parity = 1 - parity;
            j++;
        }

        if (needed)
            parity = 1 - parity;
    }
    return true;
}

int main(int argc, char *argv[]) {
    char a[MAX], b[MAX];
    cin >> a >> b;
    size_t sa = strlen(a);
    size_t sb = strlen(b);

    int parity = 0;
    for (int i = 0; i < sa; ++i)
        if (a[i] == '1')
            parity = 1 - parity;

    int pos = sa;
    int size = 0;
    bool correct = false;
    for (int i = 0; i < sa; ++i) {
        int k = 0;
        while (k < sb && i+k < sa && a[i+k] == b[k])
            k++;
        if (i+k == sa) {
            pos = i;
            size = k;
            cerr << pos << ' ' << size << endl;
            correct |= find(a, b, sa, sb, pos, size, parity);
            if (correct) break;
        }
    }

    cout << correct << endl;
    correct |= find(a, b, sa, sb, sa, 0, parity);

    if (correct)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return EXIT_SUCCESS;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;

#define MAX 10000

bool find(char *a, char *b, int sa, int sb, int pos, int size, int parity) {
    int j = 0;
    for (int i = size; i < sb; ++i) {
        int needed = b[i] - '0';

        while (parity != needed) {
            if (j == pos)
                return false;
            if (a[j] == '1')
                parity = 1 - parity;
            j++;
        }

        if (needed)
            parity = 1 - parity;
    }
    return true;
}

int main(int argc, char *argv[]) {
    char a[MAX], b[MAX];
    cin >> a >> b;
    size_t sa = strlen(a);
    size_t sb = strlen(b);

    int parity = 0;
    for (int i = 0; i < sa; ++i)
        if (a[i] == '1')
            parity = 1 - parity;

    int pos = sa;
    int size = 0;
    bool correct = false;
    for (int i = 0; i < sa; ++i) {
        int k = 0;
        while (k < sb && i+k < sa && a[i+k] == b[k])
            k++;
        if (i+k == sa) {
            pos = i;
            size = k;
            //cerr << pos << ' ' << size << endl;
            //if (correct) break;
            break;
        }
    }

    correct |= find(a, b, sa, sb, pos, size, parity);
    correct |= find(a, b, sa, sb, sa, 0, parity);

    if (correct)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return EXIT_SUCCESS;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;

int count_ones(string &v) {
    int cnt = 0;
    for (size_t i = 0; i < v.size(); ++i)
        if (v[i] == '1')
            cnt++;
    return cnt;
}

int main(int argc, char *argv[]) {
    string a, b;
    cin >> a >> b;

    int ca = count_ones(a);
    int cb = count_ones(b);

    if ( ca+ca%2 >= cb )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return EXIT_SUCCESS;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;

#define MAX 10000

bool find(char *a, char *b, int sa, int sb, int pos, int size, int parity) {
    int j = 0;
    for (int i = size; i < sb; ++i) {
        int needed = b[i] - '0';

        while (parity != needed) {
            if (j == pos)
                return false;
            if (a[j] == '1')
                parity = 1 - parity;
            j++;
        }

        if (needed)
            parity = 1 - parity;
    }
    return true;
}

int main(int argc, char *argv[]) {
    char a[MAX], b[MAX];
    cin >> a >> b;
    size_t sa = strlen(a);
    size_t sb = strlen(b);

    int parity = 0;
    for (int i = 0; i < sa; ++i)
        if (a[i] == '1')
            parity = 1 - parity;

    int pos = sa;
    int size = 0;
    bool correct = false;
    for (int i = 0; i < sa; ++i) {
        int k = 0;
        while (k < sb && i+k < sa && a[i+k] == b[k])
            k++;
        if (i+k == sa) {
            pos = i;
            size = k;
            //cerr << pos << ' ' << size << endl;
            correct |= find(a, b, sa, sb, pos, size, parity);
            if (correct) break;
        }
    }

    correct |= find(a, b, sa, sb, sa, 0, parity);

    if (correct)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return EXIT_SUCCESS;
}


#include<bits/stdc++.h>
#include<functional>
#include<string.h>
using namespace std;
#define ll   long long  int
#define mp make_pair
#define s second
#define f first
#define mod 1000000007
#define pi pair<ll,ll>
#define pb push_back
int main(){
string a,b;
cin>>a>>b;
ll n=a.length();
a='$'+a;
b='$'+b;
ll sum[a.length()+1];
sum[0]=0;
bool u=0;
for(int i=1;i<b.length();i++){
	if(b[i]!='0'){
	u=1;
	break;
	}
}
if(u==0){
	cout<<"YES";
	return 0;
}
for(int i=1;i<=a.length();i++){
	sum[i]=sum[i-1]+a[i]-'0';
}
ll add=0;
for(int i=n;i>=1;i--){
bool got=1;
if( n-i+1 >(int) b.length()-1 ) break;
for(int j=i;j<=n;j++){
	if(b[j-i+1]!=a[j]){
    got=0;
    break;
	}
}
if(got==0) continue;
ll j=n-i+2;
ll k=1;
while(j<=(int)b.length()-1){
ll p=sum[n]-sum[k-1]+add;
ll num=b[j]-'0';
if(num!=p%2){
	add++;
	if(k==i) {
	got=0;
	break;
    }
while(k<=i-1 && a[k]!='1')k++;
if(k>=i){
	got=0;
	break;
}
else{
	k++;
}
}
j++;
}
if(got==1){
	cout<<"YES";
	return 0;
}
}
cout<<"NO";
}


#include<bits/stdc++.h>
#include<functional>
#include<string.h>
using namespace std;
#define ll   long long  int
#define mp make_pair
#define s second
#define f first
#define mod 1000000007
#define pi pair<ll,ll>
#define pb push_back
int main(){
string a,b;
cin>>a>>b;
ll n=a.length();
a='$'+a;
b='$'+b;
ll sum[a.length()+1];
sum[0]=0;
for(int i=1;i<=a.length();i++){
	sum[i]=sum[i-1]+a[i]-'0';
}
ll add=0;
for(int i=n;i>=1;i--){
bool got=1;
if( n-i+1 >(int) b.length()-1 ) break;
for(int j=i;j<=n;j++){
	if(b[j-i+1]!=a[j]){
    got=0;
    break;
	}
}
if(got==0) continue;
ll j=n-i+2;
ll k=1;
while(j<=(int)b.length()-1){
ll p=sum[n]-sum[k-1]+add;
ll num=b[j]-'0';
if(num!=p%2){
	add++;
	if(k==i) {
	got=0;
	break;
    }
while(k<=i-1 && a[k]!='1')k++;
if(k>=i){
	got=0;
	break;
}
else{
	k++;
}
}
j++;
}
if(got==1){
	cout<<"YES";
	return 0;
}
}
cout<<"NO";
}


#include<bits/stdc++.h>
#include<functional>
#include<string.h>
using namespace std;
#define ll   long long  int
#define mp make_pair
#define s second
#define f first
#define mod 1000000007
#define pi pair<ll,ll>
#define pb push_back
int main(){
string a,b;
cin>>a>>b;
ll n=a.length();
a='$'+a;
b='$'+b;
ll sum[a.length()+1];
sum[0]=0;
for(int i=1;i<=a.length();i++){
	sum[i]=sum[i-1]+a[i]-'0';
}
for(int i=n;i>=1;i--){
ll p=sum[n]-sum[i-1];
bool got=1;
//if( n-i+1 >(int) b.length()-1 ) break;
for(int j=i;j<=n;j++){
	if(b[j-i+1]!=a[j]){
    got=0;
    break;
	}
}
if(got==0) continue;
ll j=n-i+2;
ll k=1;
while(j<=(int)b.length()-1){
p=sum[n]-sum[k-1];
ll num=b[j]-'0';
if(num!=p%2){
	if(k>=i) {
	got=0;
	break;
    }
while(k<=i-1 && a[k]!='1')k++;
if(k>=i){
	got=0;
	break;
}
else{
	k++;
}
}
j++;
}
if(got==1){
	cout<<"YES";
	return 0;
}
}
cout<<"NO";
}


#include<bits/stdc++.h>
#include<functional>
#include<string.h>
using namespace std;
#define ll   long long  int
#define mp make_pair
#define s second
#define f first
#define mod 1000000007
#define pi pair<ll,ll>
#define pb push_back
int main(){
string a,b;
cin>>a>>b;
ll n=a.length();
a='$'+a;
b='$'+b;
ll sum[a.length()+1];
sum[0]=0;
for(int i=1;i<=a.length();i++){
	sum[i]=sum[i-1]+a[i]-'0';
}
for(int i=n;i>=1;i--){
ll p=sum[n]-sum[i-1];
bool got=1;
if( n-i+1 >(int) b.length()-1 ) break;
for(int j=i;j<=n;j++){
	if(b[j-i+1]!=a[j]){
    got=0;
    break;
	}
}
if(got==0) continue;
ll j=n-i+2;
ll k=1;
while(j<=(int)b.length()-1){
p=sum[n]-sum[k-1];
ll num=b[j]-'0';
if(num!=p%2){
	if(k==i) {
	got=0;
	break;
    }
while(k<=i-1 && a[k]!='1')k++;
if(k>=i){
	got=0;
	break;
}
else{
	k++;
}
}
j++;
}
if(got==1){
	cout<<"YES";
	return 0;
}
}
cout<<"NO";
}


#include<bits/stdc++.h>
#include<functional>
#include<string.h>
using namespace std;
#define ll   long long  int
#define mp make_pair
#define s second
#define f first
#define mod 1000000007
#define pi pair<ll,ll>
#define pb push_back
int main(){
string a,b;
cin>>a>>b;
ll na=0,nb=0;
for(int i=0;i<a.length();i++){
	na=na+(a[i]=='1');
}
for(int i=0;i<b.length();i++){
	nb=nb+(b[i]=='1');
}
if(na%2) na++;
if(na>=nb) cout<<"YES";
else cout<<"NO";
}


#include <cstdio>
#include <algorithm>

using namespace std;

char a[1000], b[1000];

int main() {
	int n = strlen(gets(a));
	int m = strlen(gets(b));
	int p = count(a,a+n,'1');
	int q = count(b,b+n,'1');
	puts(p+p%2 >= q ? "YES":"NO");

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char a[1003], b[1003];

int main() {
	int n = strlen(gets(a));
	int m = strlen(gets(b));
	int p = count(a,a+n,'1');
	int q = count(b,b+m,'1');
	puts(p+p%2 >= q ? "YES":"NO");

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char a[1000], b[1000];

int main() {
	int n = strlen(gets(a));
	int m = strlen(gets(b));
	int p = count(a,a+n,'1');
	int q = count(b,b+n,'1');
	puts(p+p%2 >= q ? "YES":"NO");

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char a[1003], b[1003];

int main() {
	int n = strlen(gets(a));
	int m = strlen(gets(b));
	int p = count(a,a+n,'1');
	int q = count(b,b+n,'1');
	puts(p+p%2 >= q ? "YES":"NO");

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

char a[1000], b[1000];

int main() {
	int n = strlen(gets(a));
	int m = strlen(gets(b));
	int p = count(a,a+n,'1');
	int q = count(b,b+n,'1');
	puts(p+p%2 >= q ? "YES":"NO");

	return 0;
}


#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

string a,b;

int main() {
	cin >> a >> b;

	int ones = 0;
	for(int i=0;i<a.size();++i) ones += (a[i] == '1');
	for(int i=0;i<=a.size();++i) {
		if( a.substr(a.size()-i,i) == b.substr(0,i) ) {
			int ac = 0, bc = 0;
			for(int j=0;j<a.size()-i;++j) ac += (a[j] == '1');
			for(int j=i;j<b.size();++j) bc += (b[j] == '1');

			if(i == b.size()) {
				printf("YES");
				return 0;
			}
			else if(b[i] == '0') {
				if(ones % 2) ac--;
				if(ac >= bc) {
					printf("YES");
					return 0;
				}
			}
			else {
				if(ones % 2 == 0) ac--;
				else bc--;
				if(ac >= bc) {
					printf("YES");
					return 0;
				}
			}
		}
	}

	printf("NO");
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string a,b;

int main() {
    cin >> a >> b;

    if( count(a.begin(), a.end(), '1') >= count(b.begin(), b.end(), '1') )
        printf("YES");
    else
        printf("NO");

    return 0;

    int ones = 0;
    for(int i=0;i<a.size();++i) ones += (a[i] == '1');
    for(int i=0;i<=a.size();++i) {
        if( a.substr(a.size()-i,i) == b.substr(0,i) ) {
            int ac = 0, bc = 0;
            for(int j=0;j<a.size()-i;++j) ac += (a[j] == '1');
            for(int j=i;j<b.size();++j) bc += (b[j] == '1');

            if(i == b.size()) {
                printf("YES");
                return 0;
            }
            else if(b[i] == '0') {
                if(ones % 2) ac--;
                if(ac >= bc) {
                    printf("YES");
                    return 0;
                }
            }
            else {
                if(ones % 2 == 0) ac--;
                else bc--;
                if(ac >= bc) {
                    printf("YES");
                    return 0;
                }
            }
        }
    }

    printf("NO");
}


#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

string a,b;

int main() {
	cin >> a >> b;

	for(int i=0;i<=a.size();++i) {
		if( a.substr(a.size()-i,i) == b.substr(0,i) ) {
			bool have_one = false;
			int  start    = 0;
			for(int j=0;j<a.size()-i;++j) if( a[j] == '1' )
				have_one = true;
			for(int j=a.size()-i;j<a.size();++j)
				start ^= (a[j] - '0');

			bool ok;

			int ori_start=start;
			if(have_one) {

				ok = 1, start = ori_start;
				for(int j=i;j<b.size();++j) {
					if(b[j]-'0' != start) ok = 0;
					start ^= 1;
				}

				if(ok) {
					printf("YES");
					return 0;
				}

				ok = 1, start = ori_start ^ 1;
				for(int j=i;j<b.size();++j) {
					if(b[j]-'0' != start) ok = 0;
					start ^= 1;
				}

				if(ok) {
					printf("YES");
					return 0;
				}
			}
			else {

				ok = 1;
				for(int j=i;j<b.size();++j) {
					if(b[j]-'0' != start) ok = 0;
					start ^= 1;
				}

				if(ok) {
					printf("YES");
					return 0;
				}

			}
		}
	}

	printf("NO");
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string a,b;

int main() {
    cin >> a >> b;

    if( count(a.begin(), a.end(), '1') == count(b.begin(), b.end(), '1') )
        printf("YES");
    else
        printf("NO");

    return 0;

    int ones = 0;
    for(int i=0;i<a.size();++i) ones += (a[i] == '1');
    for(int i=0;i<=a.size();++i) {
        if( a.substr(a.size()-i,i) == b.substr(0,i) ) {
            int ac = 0, bc = 0;
            for(int j=0;j<a.size()-i;++j) ac += (a[j] == '1');
            for(int j=i;j<b.size();++j) bc += (b[j] == '1');

            if(i == b.size()) {
                printf("YES");
                return 0;
            }
            else if(b[i] == '0') {
                if(ones % 2) ac--;
                if(ac >= bc) {
                    printf("YES");
                    return 0;
                }
            }
            else {
                if(ones % 2 == 0) ac--;
                else bc--;
                if(ac >= bc) {
                    printf("YES");
                    return 0;
                }
            }
        }
    }

    printf("NO");
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string a,b;

int main() {
    cin >> a >> b;

    int A = count(a.begin(), a.end(), '1');
    int B = count(b.begin(), b.end(), '1');
    if(A%2) A++;
    if( A >= B )
        printf("YES");
    else
        printf("NO");

    return 0;

}


#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

string a,b;

int main() {
	cin >> a >> b;

	int ones = 0;
	for(int i=0;i<a.size();++i) ones += (a[i] == '1');
	for(int i=0;i<=a.size();++i) {
		if( a.substr(a.size()-i,i) == b.substr(0,i) ) {
			int ac = 0, bc = 0;
			for(int j=0;j<a.size()-i;++j) ac += (a[j] == '1');
			for(int j=i;j<b.size();++j) bc += (b[j] == '1');

			if(b[i] == '0') {
				if(ones % 2) ac--;
				if(ac >= bc) {
					printf("YES");
					return 0;
				}
			}
			else {
				if(ones % 2 == 0) ac--;
				if(ac >= bc) {
					printf("YES");
					return 0;
				}
			}
		}
	}

	printf("NO");
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int sum=0;
	for(int i=0; i<la; ++i) if(a[i]=='1') ++sum;
	if(sum&1) ++sum;
	for(int i=0; i<lb; ++i) if(b[i]=='1') --sum;
	if(sum>=0) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1; int j=0;
		for(j=0; j<=tail; ++j) {
			if(i+j>=la || a[i+j]!=b[j]) { flag=0; break; }
		}
		if(!flag && i+j==la) {
			flag=1;
			for(; j<lb; ++j) { if(b[j]!=a[la-1]) { flag=0; break; } }
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1; int j=0, add=0;
		for(j=0; j<=tail; ++j) {
			if(i+j>=la || a[i+j]!=b[j]) { flag=0; break; }
			if(a[i+j]=='1') add^=1;
		} printf("%d %d\n", i, add);
		if(!flag && i+j==la) {
			flag=1;
			for(; j<lb; ++j) { if(b[j]!='0'+add) { flag=0; printf("%c ", b[j]); break; } if(add) add=0; }
			printf("%d\n", flag);
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1; int j=0, add=0;
		for(j=0; j<=tail; ++j) {
			if(i+j>=la || a[i+j]!=b[j]) { flag=0; break; }
			if(a[i+j]=='1') add^=1;
		}
		if(!flag && i+j==la) {
			flag=1;
			for(; j<lb; ++j) { if(b[j]!='0'+add) { flag=0; printf("%c ", b[j]); break; } if(add) add=0; }
			printf("%d\n", flag);
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1; int j=0, add=0;
		for(j=0; j<=tail; ++j) {
			if(i+j>=la || a[i+j]!=b[j]) { flag=0; break; }
			if(a[i+j]=='1') add^=1;
		}
		if(!flag && i+j==la) {
			flag=1;
			for(; j<lb; ++j) { if(b[j]!='0'+add) { flag=0; break; } if(add) add=0; }
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1; int j=0, add=0;
		for(j=0; j<=tail; ++j) {
			if(i+j>=la || a[i+j]!=b[j]) { flag=0; break; }
			if(a[i+j]) add^=1;
		}
		if(!flag && i+j==la) {
			flag=1;
			for(; j<lb; ++j) { if(b[j]!=add) { flag=0; break; } }
			add^=1;
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int front=0, tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1;
		for(int j=front; j<=tail; ++j) {
			if(a[i+j-front]!=b[j]) { flag=0; break; }
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1; int j=0;
		for(j=0; j<=tail; ++j) {
			if(i+j>=la || a[i+j]!=b[j]) { flag=0; break; }
		}
		if(i+j==la) {
			flag=1;
			for(; j<lb; ++j) { if(b[j]!=a[la-1]) { flag=0; break; } }
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

char a[1005], b[1005];
int la, lb;
int main() {
	scanf("%s%s", a, b);
	la=strlen(a), lb=strlen(b);
	int tail=-1;
	for(int i=0; i<lb; ++i) {
		if(b[i]=='1') {
			tail=max(tail, i);
		}
	}
	bool f=0;
	for(int i=0; i<la; ++i) {
		bool flag=1; int j=0, add=0;
		for(j=0; j<=tail; ++j) {
			if(i+j>=la || a[i+j]!=b[j]) { flag=0; break; }
			if(a[i+j]=='1') add^=1;
		}
		if(!flag && i+j==la) {
			flag=1;
			for(; j<lb; ++j) { if(b[j]!='0'+add) { flag=0; break; } if(add) add=0; }
			printf("%d\n", flag);
		}
		if(flag) { f=1; break; }
	}
	if(f) puts("YES");
	else puts("NO");
	return 0;
}


#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn=1000+10;

string a,b;
int n,m,head,next[maxn],one;

void init()
{
	cin >> a;
	cin >> b;
	n=a.length();
	m=b.length();
	head=-1; one=0;
	for (int i=n-1; i>=0; i--)
		if (a[i]=='1')
		{
			next[i]=head; head=i;
			one++;
		}
}

void solve()
{
	int q,s;
	bool flag;

	for (int p=0; p<=n; p++)
	{
		flag=true;
		for (int i=p; i<n; i++)
			if (i-p>=m || a[i]!=b[i-p])
			{
				flag=false; break;
			}
		if (!flag) continue;
		q=head; s=one;
		for (int i=n-p; i<m; i++)
		{
			if (b[i]=='0' && s%2==1 || b[i]=='1' && s%2==0)
			{
				if (q>=p || q==-1) {flag=false; break;}
				q=next[q]; s--;
			}
			if (b[i]=='1') s++;
		}
		if (flag)
		{
			cout << "YES" << endl;
			return;
		}
	}
	if (one%2)
	{
		a.push_back('1'); n++;
		head=-1; one=0;
		for (int i=n-1; i>=0; i--)
			if (a[i]=='1')
			{
				next[i]=head; head=i;
				one++;
			}
		for (int p=0; p<=n; p++)
		{
			flag=true;
			for (int i=p; i<n; i++)
				if (i-p>=m || a[i]!=b[i-p])
				{
					flag=false; break;
				}
			if (!flag) continue;
			q=head; s=one;
			for (int i=n-p; i<m; i++)
			{
				if (b[i]=='0' && s%2==1 || b[i]=='1' && s%2==0)
				{
					if (q>=p || q==-1) {flag=false; break;}
					q=next[q]; s--;
				}
				if (b[i]=='1') s++;
			}
			if (flag)
			{
				cout << "YES" << endl;
				return;
			}
		}
	}

	cout << "NO" << endl;
}

int main()
{
	init();
	solve();

	return 0;
}


#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn=1000+10;

string a,b;
int n,m,head,next[maxn],one;

void init()
{
	cin >> a;
	cin >> b;
	n=a.length();
	m=b.length();
	head=-1; one=0;
	for (int i=n-1; i>=0; i--)
		if (a[i]=='1')
		{
			next[i]=head; head=i;
			one++;
		}
}

void solve()
{
	int q,s;
	bool flag;

	for (int p=0; p<n; p++)
	{
		flag=true;
		for (int i=p; i<n; i++)
			if (i-p>=m || a[i]!=b[i-p])
			{
				flag=false; break;
			}
		if (!flag) continue;
		q=head; s=one;
		for (int i=n-p; i<m; i++)
			if (b[i]=='0' && s%2==1 || b[i]=='1' && s%2==0)
			{
				if (q>=p || q==-1) {flag=false; break;}
				q=next[q]; s--;
			}
		if (flag)
		{
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << endl;
}

int main()
{
	init();
	solve();

	return 0;
}


#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn=1000+10;

string a,b;
int n,m,head,next[maxn],one;

void init()
{
	cin >> a;
	cin >> b;
	n=a.length();
	m=b.length();
	head=-1; one=0;
	for (int i=n-1; i>=0; i--)
		if (a[i]=='1')
		{
			next[i]=head; head=i;
			one++;
		}
}

void solve()
{
	int q,s;
	bool flag;

	for (int p=0; p<n; p++)
	{
		flag=true;
		for (int i=p; i<n; i++)
			if (i-p>=m || a[i]!=b[i-p])
			{
				flag=false; break;
			}
		if (!flag) continue;
		q=head; s=one;
		for (int i=n-p; i<m; i++)
			if (b[i]=='0' && s%2==1 || b[i]=='1' && s%2==0)
			{
				if (q>=p) {flag=false; break;}
				q=next[q]; s--;
			}
		if (flag)
		{
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << endl;
}

int main()
{
	init();
	solve();

	return 0;
}


#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn=1000+10;

string a,b;
int n,m,head,next[maxn],one;

void init()
{
	cin >> a;
	cin >> b;
	n=a.length();
	m=b.length();
	head=-1; one=0;
	for (int i=n-1; i>=0; i--)
		if (a[i]=='1')
		{
			next[i]=head; head=i;
			one++;
		}
}

void solve()
{
	int q,s;
	bool flag;

	for (int p=0; p<=n; p++)
	{
		flag=true;
		for (int i=p; i<n; i++)
			if (i-p>=m || a[i]!=b[i-p])
			{
				flag=false; break;
			}
		if (!flag) continue;
		q=head; s=one;
		for (int i=n-p; i<m; i++)
			if (b[i]=='0' && s%2==1 || b[i]=='1' && s%2==0)
			{
				if (q>=p || q==-1) {flag=false; break;}
				q=next[q]; s--;
			}
		if (flag)
		{
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << endl;
}

int main()
{
	init();
	solve();

	return 0;
}


#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn=1000+10;

string a,b;
int n,m,head,next[maxn],one;

void init()
{
	cin >> a;
	cin >> b;
	n=a.length();
	m=b.length();
	head=-1; one=0;
	for (int i=n-1; i>=0; i--)
		if (a[i]=='1')
		{
			next[i]=head; head=i;
			one++;
		}
}

void solve()
{
	int q,s;
	bool flag;

	flag=false;
	for (int i=0; i<m; i++)
		if (b[i]=='1') flag=true;
	if (!flag)
	{
		cout << "YES" << endl;
		return;
	}
	for (int p=0; p<n; p++)
	{
		flag=true;
		for (int i=p; i<n; i++)
			if (i-p>=m || a[i]!=b[i-p])
			{
				flag=false; break;
			}
		if (!flag) continue;
		q=head; s=one;
		for (int i=n-p; i<m; i++)
			if (b[i]=='0' && s%2==1 || b[i]=='1' && s%2==0)
			{
				if (q>=p || q==-1) {flag=false; break;}
				q=next[q]; s--;
			}
		if (flag)
		{
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << endl;
}

int main()
{
	init();
	solve();

	return 0;
}


#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn=1000+10;

string a,b;
int n,m,head,next[maxn],one;

void init()
{
	cin >> a;
	cin >> b;
	n=a.length();
	m=b.length();
	head=-1; one=0;
	for (int i=n-1; i>=0; i--)
		if (a[i]=='1')
		{
			next[i]=head; head=i;
			one++;
		}
}

void solve()
{
	int q,s;
	bool flag;

	for (int p=0; p<=n; p++)
	{
		flag=true;
		for (int i=p; i<n; i++)
			if (i-p>=m || a[i]!=b[i-p])
			{
				flag=false; break;
			}
		if (!flag) continue;
		q=head; s=one;
		for (int i=n-p; i<m; i++)
		{
			if (b[i]=='0' && s%2==1 || b[i]=='1' && s%2==0)
			{
				if (q>=p || q==-1) {flag=false; break;}
				q=next[q]; s--;
			}
			if (b[i]=='1') s++;
		}
		if (flag)
		{
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << endl;
}

int main()
{
	init();
	solve();

	return 0;
}


// I AM BACK!!!

#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>

using namespace std;

#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define rep(i,m) for(int i=0;i<(int)(m);i++)
#define rep2(i,n,m) for(int i=n;i<(int)(m);i++)
#define For(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define dot(a,b) ((conj(a)*(b)).X)
#define X real()
#define Y imag()
#define length(V) (hypot((V).X,(V).Y))
#define vect(a,b) ((b)-(a))
#define cross(a,b) ((conj(a)*(b)).imag())
#define normalize(v) ((v)/length(v))
#define rotate(p,about,theta) ((p-about)*exp(point(0,theta))+about)
#define pointEqu(a,b) (comp(a.X,b.X)==0 && comp(a.Y,b.Y)==0)

typedef stringstream ss;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vii;
typedef long double ld;
typedef complex<double> point;
typedef pair<point, point> segment;
typedef pair<double, point> circle;
typedef vector<point> polygon;

const int oo = (int) 1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;

int n, m, N, M, I, J;
int di[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dj[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
bool val(const int& i, const int& j) {
    return i >= 0 && i < I && j >= 0 && j < J;
}
int comp(const double& a, const double& b) {
    if (fabs(a - b) < eps)
        return 0;
    return a < b ? -1 : 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("a.txt", "rt", stdin);
    //freopen("b.txt", "wt", stdout);
#endif
    string s1, s2;
    cin >> s1 >> s2;
    int c1 = 0, c2 = 0;
    rep(i,sz(s1))
        c1 += s1[i] - '0';
    rep(i,sz(s2))
        c2 += s2[i] - '0';
    if (c1 % 2)
        c1++;
    if (c1 >= c2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


// I AM BACK!!!

#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>

using namespace std;

#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define rep(i,m) for(int i=0;i<(int)(m);i++)
#define rep2(i,n,m) for(int i=n;i<(int)(m);i++)
#define For(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define dot(a,b) ((conj(a)*(b)).X)
#define X real()
#define Y imag()
#define length(V) (hypot((V).X,(V).Y))
#define vect(a,b) ((b)-(a))
#define cross(a,b) ((conj(a)*(b)).imag())
#define normalize(v) ((v)/length(v))
#define rotate(p,about,theta) ((p-about)*exp(point(0,theta))+about)
#define pointEqu(a,b) (comp(a.X,b.X)==0 && comp(a.Y,b.Y)==0)

typedef stringstream ss;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vii;
typedef long double ld;
typedef complex<double> point;
typedef pair<point, point> segment;
typedef pair<double, point> circle;
typedef vector<point> polygon;

const int oo = (int) 1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;

int n, m, N, M, I, J;
int di[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dj[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
bool val(const int& i, const int& j) {
    return i >= 0 && i < I && j >= 0 && j < J;
}
int comp(const double& a, const double& b) {
    if (fabs(a - b) < eps)
        return 0;
    return a < b ? -1 : 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("a.txt", "rt", stdin);
    //freopen("b.txt", "wt", stdout);
#endif
    string s1, s2;
    cin >> s1 >> s2;
    rep(i,sz(s1)+1)
    {
        string s4 = s1.substr(i);
        int c = 0;
        rep(j,sz(s4))
            c ^= s4[j] - '0';
        while (sz(s4) < sz(s2) ) {
            s4 += char(c + '0');
            c ^= c;
        }
        if (s4 == s2) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


// I AM BACK!!!

#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>

using namespace std;

#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define rep(i,m) for(int i=0;i<(int)(m);i++)
#define rep2(i,n,m) for(int i=n;i<(int)(m);i++)
#define For(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define dot(a,b) ((conj(a)*(b)).X)
#define X real()
#define Y imag()
#define length(V) (hypot((V).X,(V).Y))
#define vect(a,b) ((b)-(a))
#define cross(a,b) ((conj(a)*(b)).imag())
#define normalize(v) ((v)/length(v))
#define rotate(p,about,theta) ((p-about)*exp(point(0,theta))+about)
#define pointEqu(a,b) (comp(a.X,b.X)==0 && comp(a.Y,b.Y)==0)

typedef stringstream ss;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vii;
typedef long double ld;
typedef complex<double> point;
typedef pair<point, point> segment;
typedef pair<double, point> circle;
typedef vector<point> polygon;

const int oo = (int) 1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;

int n, m, N, M, I, J;
int di[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dj[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
bool val(const int& i, const int& j) {
    return i >= 0 && i < I && j >= 0 && j < J;
}
int comp(const double& a, const double& b) {
    if (fabs(a - b) < eps)
        return 0;
    return a < b ? -1 : 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("a.txt", "rt", stdin);
    //freopen("b.txt", "wt", stdout);
#endif
    string s1, s2;
    cin >> s1 >> s2;
    int c = 0;
    string s3 = "";
    int mn = min(sz(s1), sz(s2) );
    rep(i,mn+1)
    {
        string s4 = s3;
        int c2 = c;
        while (sz(s4) < sz(s2) ) {
            s4 += char(c2 + '0');
            c2 ^= c2;
        }
        if (s4 == s2) {
            cout << "YES" << endl;
            return 0;
        }
        if (i < mn) {
            s3 += s1[i];
            c ^= s1[i] - '0';
        }
    }
    cout << "NO" << endl;
    return 0;
}


// I AM BACK!!!

#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>

using namespace std;

#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define rep(i,m) for(int i=0;i<(int)(m);i++)
#define rep2(i,n,m) for(int i=n;i<(int)(m);i++)
#define For(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define dot(a,b) ((conj(a)*(b)).X)
#define X real()
#define Y imag()
#define length(V) (hypot((V).X,(V).Y))
#define vect(a,b) ((b)-(a))
#define cross(a,b) ((conj(a)*(b)).imag())
#define normalize(v) ((v)/length(v))
#define rotate(p,about,theta) ((p-about)*exp(point(0,theta))+about)
#define pointEqu(a,b) (comp(a.X,b.X)==0 && comp(a.Y,b.Y)==0)

typedef stringstream ss;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vii;
typedef long double ld;
typedef complex<double> point;
typedef pair<point, point> segment;
typedef pair<double, point> circle;
typedef vector<point> polygon;

const int oo = (int) 1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;

int n, m, N, M, I, J;
int di[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dj[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
bool val(const int& i, const int& j) {
    return i >= 0 && i < I && j >= 0 && j < J;
}
int comp(const double& a, const double& b) {
    if (fabs(a - b) < eps)
        return 0;
    return a < b ? -1 : 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("a.txt", "rt", stdin);
    //freopen("b.txt", "wt", stdout);
#endif
    string s1, s2;
    cin >> s1 >> s2;
    int c = 0;
    string s3 = "";
    int mn = min(sz(s1), sz(s2) );
    rep(i,mn+1)
    {
        string s4 = s3;
        int c2 = c;
        while (sz(s4) < sz(s2) ) {
            s4 += char(c2 + '0');
            c2 ^= c2;
        }
        if (s4 == s2) {
            cout << "YES" << endl;
            return 0;
        }
        if (i < mn) {
            s3 += s1[i];
            c += s1[i] - '0';
        }
    }
    cout << "NO" << endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

#define N 1004
#define M
#define LL __int64
#define INF 0x3f7f7f7f
char a[N], b[N];
int next[N], la, lb;
void getnext(void)
{
    int j = 0, i;
    next[1] = 0;
    for(i = 2; i <= lb; i++)
    {
        while(j > 0 && b[j + 1] != b[i])    j = next[j];
        if(b[j + 1] == b[i])    j ++;
        next[i] = j;
    }
}

int kmp(void)
{
    int i, j = 0;
    for(i = 1; i <= la; i++)
    {
        while(j  > 0 && a[i] != b[j + 1])   j = next[j];
        if(b[j + 1] == a[i])    j++;
        if(i == la)  return j;
        if(j == lb)
        {
            j = next[j];        //етРяетРяЃЁ
        }
    }
}
int main(void)
{
    int  i, j, f, r, aone = 0, savea = 0, ta, sa;
    scanf("%s%s", a + 1, b + 1);
    la = strlen(a + 1); lb = strlen(b + 1);
    getnext();
    f = kmp();
    if(f == lb)    {
        printf("YES\n");
        return 0;
    }

    for(i = 1; i <= la - f; i++){
            if(a[i] == '1')aone ++;
    }
    for(; i <= la; i++){
        if(a[i] == '1') savea ++;
    }
    bool flag = false;
    for(i = la - f + 1; i <= la; i++){
     //   printf("%d\n", i);
        if(strstr(b + 1, a + i) != (b + 1)){
            if(a[i] == '1') {
                aone ++;
                savea --;
                continue;
            }
        }
        ta = aone;  sa = savea;
        for(j = la - i + 2; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
            break;
        }
        if(a[i] == '1') {
            savea--;
            aone++;
        }
    }
    if(!flag) {
        ta = aone;  sa = 0;
        for(j = 1; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
        }
    }
    printf("%s\n", flag ? "YES" : "NO");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

#define N 1004
#define M
#define LL __int64
#define INF 0x3f7f7f7f
char a[N], b[N];
int next[N], la, lb;
void getnext(void)
{
    int j = 0, i;
    next[1] = 0;
    for(i = 2; i <= lb; i++)
    {
        while(j > 0 && b[j + 1] != b[i])    j = next[j];
        if(b[j + 1] == b[i])    j ++;
        next[i] = j;
    }
}

int kmp(void)
{
    int i, j = 0;
    for(i = 1; i <= la; i++)
    {
        while(j  > 0 && a[i] != b[j + 1])   j = next[j];
        if(b[j + 1] == a[i])    j++;
        if(j == lb && i == la)
        {
            return INF;
            j = next[j];        //етРяетРяЃЁ
        }
    }
    return j;
}
int main(void)
{
    int  i, j, f, r, aone = 0, savea = 0, ta, sa;
    scanf("%s%s", a + 1, b + 1);
    la = strlen(a + 1); lb = strlen(b + 1);
    getnext();
    f = kmp();
    if(f == INF)    {
        printf("YES\n");
        return 0;
    }

    for(i = 1; i < la - f + 1; i++){
            if(a[i] == '1')aone ++;
    }
    for(; i <= la; i++){
        if(a[i] == '1') savea ++;
    }
    bool flag = false;
    for(i = la - f + 1; i <= la; i++){
     //   printf("%d\n", i);
        if(strstr(b + 1, a + i) != (b + 1)){
            if(a[i] == '1') {
                aone ++;
                savea --;
                continue;
            }
        }
        ta = aone;  sa = savea;
        for(j = la - i + 2; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
            break;
        }
        if(a[i] == '1') {
            savea--;
            aone++;
        }
    }
    if(!flag) {
        ta = aone;  sa = savea;
        for(j = 1; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
        }
    }
    printf("%s\n", flag ? "YES" : "NO");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

#define N 1004
#define M
#define LL __int64
#define INF 0x3f7f7f7f
char a[N], b[N];
int next[N], la, lb;
void getnext(void)
{
    int j = 0, i;
    next[1] = 0;
    for(i = 2; i <= lb; i++)
    {
        while(j > 0 && b[j + 1] != b[i])    j = next[j];
        if(b[j + 1] == b[i])    j ++;
        next[i] = j;
    }
}

int kmp(void)
{
    int i, j = 0;
    for(i = 1; i <= la; i++)
    {
        while(j  > 0 && a[i] != b[j + 1])   j = next[j];
        if(b[j + 1] == a[i])    j++;
        if(i == la)  return j;
        if(j == lb)
        {
            j = next[j];        //етРяетРяЃЁ
        }
    }
}
int main(void)
{
    int  i, j, f, r, aone = 0, savea = 0, ta, sa;
    scanf("%s%s", a + 1, b + 1);
    la = strlen(a + 1); lb = strlen(b + 1);
    getnext();
    f = kmp();
    if(f == lb)    {
        printf("YES\n");
        return 0;
    }

    for(i = 1; i <= la - f; i++){
        if(a[i] == '1')aone ++;
    }
    for(; i <= la; i++){
        if(a[i] == '1') savea ++;
    }
    bool flag = false;
    for(i = la - f + 1; i <= la; i++){
     //   printf("%d\n", i);
        if(strstr(b + 1, a + i) != (b + 1)){
            if(a[i] == '1') {
                aone ++;
                savea --;
                continue;
            }
        }
        ta = aone;  sa = savea;
        for(j = la - i + 2; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
            break;
        }
        if(a[i] == '1') {
            savea--;
            aone++;
        }
    }
    if(!flag) {
        ta = aone;  sa = 0;
        if(ta & 1) ta++;
        for(j = 1; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
        }
    }
    printf("%s\n", flag ? "YES" : "NO");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

#define N 1004
#define M
#define LL __int64
#define INF 0x3f7f7f7f
char a[N], b[N];
int next[N], la, lb;
void getnext(void)
{
    int j = 0, i;
    next[1] = 0;
    for(i = 2; i <= lb; i++)
    {
        while(j > 0 && b[j + 1] != b[i])    j = next[j];
        if(b[j + 1] == b[i])    j ++;
        next[i] = j;
    }
}

int kmp(void)
{
    int i, j = 0;
    for(i = 1; i <= la; i++)
    {
        while(j  > 0 && a[i] != b[j + 1])   j = next[j];
        if(b[j + 1] == a[i])    j++;
        if(j == lb && i == la)  return INF;
        if(j == lb)
        {
            j = next[j];        //етРяетРяЃЁ
        }
    }
    return j;
}
int main(void)
{
    int  i, j, f, r, aone = 0, savea = 0, ta, sa;
    scanf("%s%s", a + 1, b + 1);
    la = strlen(a + 1); lb = strlen(b + 1);
    getnext();
    f = kmp();
    if(f == INF)    {
        printf("YES\n");
        return 0;
    }

    for(i = 1; i <= la - f; i++){
            if(a[i] == '1')aone ++;
    }
    for(; i <= la; i++){
        if(a[i] == '1') savea ++;
    }
    bool flag = false;
    for(i = la - f + 1; i <= la; i++){
     //   printf("%d\n", i);
        if(strstr(b + 1, a + i) != (b + 1)){
            if(a[i] == '1') {
                aone ++;
                savea --;
                continue;
            }
        }
        ta = aone;  sa = savea;
        for(j = la - i + 2; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
            break;
        }
        if(a[i] == '1') {
            savea--;
            aone++;
        }
    }
    if(!flag) {
        ta = aone;  sa = 0;
        for(j = 1; j <= lb; j++){
            if(b[j] == '1'){
                if((ta + sa) & 1){
                    sa ++;
                }
                else if(ta == 0)    break;
                else if(ta > 0){
                    ta --;  sa ++;
                }
            }
            else {
                if(((ta + sa) & 1) == 0)    continue;
                else if(ta == 0)    break;
                else if(ta > 0) ta --;
            }
        }
        if(j == lb + 1) {
            flag = true;
        }
    }
    printf("%s\n", flag ? "YES" : "NO");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char a[1005],b[1005];
int lena,lenb;
int num[1005];

bool cal()
{
    for (int i = 0; i <= lena; ++i)
    {
        bool ok = true;
        for (int j = i; j < lena && j - i < lenb; ++j)
            if (a[j] != b[j - i])
            {
                ok = false;
            }
        if (ok)
        {
            int p = 0,q = lena - i;
            while(p < i && q < lenb)
            {
                if (b[q] == '0')
                {
                    if (num[p] % 2 == 0)
                        q++;
                    else
                    {
                        while(p <= i && num[p] % 2 != 0)
                            p++;
                        if (p > i && num[p] % 2 != 0)
                            return false;
                        else q++;
                    }
                }else
                {
                    if (num[p] % 2 == 1)
                    {
                        q++;
                    }else
                    {
                        while(p <= i && num[p] % 2 == 0)
                            p++;
                        if (p > i && num[p] % 2 == 0)
                            return false;
                        else q++;
                    }
                }
            }
            if (q >= lenb)
                return true;
            else return false;
        }
    }
}
int main()
{
    scanf("%s%s",a,b);
    lena = strlen(a);
    lenb = strlen(b);
    num[lena] = 0;
    for (int i = lena -1; i >=0 ; --i)
    {
        if (a[i] == '1')
            num[i] = num[i + 1] + 1;
        else num[i] = num[i + 1];
    }
    if (cal())
        printf("YES\n");
    else printf("NO\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char a[1005],b[1005];
int lena,lenb;
int num[1005];

bool cal2()
{
    int ca=num[0],cb=0;
    for (int i = 0; i < lenb; ++i)
        cb += (b[i]=='1');
    if (ca+(ca&1) >= cb)
        return true;
    else return false;
}
int main()
{
    scanf("%s%s",a,b);
    lena = strlen(a);
    lenb = strlen(b);
    num[lena] = 0;
    for (int i = lena -1; i >=0 ; --i)
    {
        if (a[i] == '1')
            num[i] = num[i + 1] + 1;
        else num[i] = num[i + 1];
    }
    if (cal2())
        printf("YES\n");
    else printf("NO\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char a[1005],b[1005];
int lena,lenb;
int num[1005];

bool cal()
{
    int sum = num[0];
    int pre = num[0];
    for (int i = 0; i < lenb; ++i)
    {
        if (b[i] == '0')
        {
            if (sum % 2 != 0)
                pre--;
        }else if (sum % 2 == 0)
            pre--;
        if (pre < 0)
            return false;
        if (b[i] == '1')
            sum++;
    }
    return true;
}
int main()
{
    scanf("%s%s",a,b);
    lena = strlen(a);
    lenb = strlen(b);
    num[lena] = 0;
    for (int i = lena -1; i >=0 ; --i)
    {
        if (a[i] == '1')
            num[i] = num[i + 1] + 1;
        else num[i] = num[i + 1];
    }
    if (cal())
        printf("YES\n");
    else printf("NO\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char a[1005],b[1005];
int lena,lenb;
int num[1005];

bool cal()
{
    int loc = lena;
    for (int i = 0; i <= lena; ++i)
    {
        bool ok = true;
        for (int j = i; j < lena && j - i < lenb; ++j)
            if (a[j] != b[j - i])
            {
                ok = false;
            }
        if (ok)
        {
            loc = i;break;
        }
    }
    for (int i = lena - loc; i < lenb; ++i)
    {
        if (b[i] == '0')
        {
            if (num[0] % 2 != 0)
                num[0]--;
        }else if (num[0] % 2 == 0)
            num[0]--;
        if (num[0] < num[loc])
            return false;
    }
    return true;
}
int main()
{
    scanf("%s%s",a,b);
    lena = strlen(a);
    lenb = strlen(b);
    num[lena] = 0;
    for (int i = lena -1; i >=0 ; --i)
    {
        if (a[i] == '1')
            num[i] = num[i + 1] + 1;
        else num[i] = num[i + 1];
    }
    if (cal())
        printf("YES\n");
    else printf("NO\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char a[1005],b[1005];
int lena,lenb;
int num[1005];

bool cal()
{
    int sum = num[0];
    int pre = num[0];
    for (int i = 0; i < lenb; ++i)
    {
        if (b[i] == '0')
        {
            if (sum % 2 != 0)
                pre--,sum--;
        }else if (sum % 2 == 0)
            pre--,sum--;
        if (pre < 0)
            return false;
        if (b[i] == '1')
            sum++;
    }
    return true;
}

int main()
{
    scanf("%s%s",a,b);
    lena = strlen(a);
    lenb = strlen(b);
    num[lena] = 0;
    for (int i = lena -1; i >=0 ; --i)
    {
        if (a[i] == '1')
            num[i] = num[i + 1] + 1;
        else num[i] = num[i + 1];
    }
    if (cal())
        printf("YES\n");
    else printf("NO\n");
    return 0;
}


/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define sz size()

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int main(){

    string a,b;
    cin >> a >> b;

    int now=0;

    REP(i,a.sz+1)
    {
        bool ok=1;

        int k=i,p=0,tmp=now;

        REP(j,b.sz)
        {
            if(k<a.sz)
            {
                if(a[k]!=b[j])
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');

                k++;
            }
            else
            {
                while( p<i && tmp%2!=(b[j]-'0') && tmp>0 )
                 tmp-=(a[p]=='1'),p++;

                if( tmp%2 != (b[j]-'0') )
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');
            }
        }

        if(ok)
        {
            P("YES");
            return 0;
        }

        if(i<a.sz) now+=(a[i]=='1');
    }

    P("NO");

}


/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define sz size()

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int main(){

    string a,b;
    cin >> a >> b;

    int now=0;

    REP(i,a.sz+1)
    {
        bool ok=1;

        int k=i,p=0,tmp=now;

        REP(j,b.sz)
        {
            if(k<a.sz)
            {
                if(a[k]!=b[j])
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');

                k++;
            }
            else
            {
                while( p<i && tmp%2!=(b[j]-'0') && tmp>0 )
                 tmp-=(a[p]=='1'),p++;

                if( tmp%2 != (b[j]-'0') )
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');
            }
        }

        if(k<a.sz) ok=0;

        if(ok)
        {
            P("YES");
            return 0;
        }

        if(i<a.sz) now+=(a[i]=='1');
    }

    P("NO");

}


/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define sz size()

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int main(){

    string a,b;
    cin >> a >> b;

    int numa=0,numb=0;

    REP(i,a.sz)
     numa+=(a[i]=='1');

    REP(i,b.sz)
     numb+=(b[i]=='1');

    if(numa>=numb) P("YES");
    else P("NO");

}


/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define sz size()

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int main(){

    string a,b;
    cin >> a >> b;

    int now=0;

    REP(i,a.sz+1)
    {
        bool ok=1;

        int k=i,p=0,tmp=now;

        REP(j,b.sz)
        {
            if(k<a.sz)
            {
                if(a[k]!=b[j])
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');

                k++;
            }
            else
            {
                while( p<i && tmp%2!=(b[j]-'0') && tmp>0 )
                 tmp-=(a[p]=='1'),p++;

                if( tmp%2 != (b[j]-'0') )
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');
            }
        }

        if(k<a.sz) ok=0;

        if(ok)
        {
            P("YES");
            return 0;
        }

        if(i<a.sz) now+=(a[i]=='1');
    }

    if(now%2) a+='1',now++;
    else
    {
        P("NO");
        return 0;
    }

    bool ok=1;

    int p=0;

    REP(j,b.sz)
    {
        while( p<a.sz && now%2!=(b[j]-'0') && now>0 )
         now-=(a[p]=='1'),p++;

        if( now%2 != (b[j]-'0') )
        {
            ok=0;
            break;
        }

        now+=(b[j]=='1');
    }

    if(ok) P("YES");
    else P("NO");

}


/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<utility>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define sz size()

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int main(){

    string a,b;
    cin >> a >> b;

    int now=0;

    REP(i,a.sz+1)
    {
        bool ok=1;

        int k=i,p=0,tmp=now;

        REP(j,b.sz)
        {
            if(k<a.sz)
            {
                if(a[k]!=b[j])
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');

                k++;
            }
            else
            {
                while( p<i && tmp%2!=(b[j]-'0') )
                 tmp-=(a[p]=='1'),p++;

                if( tmp%2 != (b[j]-'0') )
                {
                    ok=0;
                    break;
                }

                tmp+=(b[j]=='1');
            }
        }

        if(ok)
        {
            P("YES");
            return 0;
        }

        if(i<a.sz) now+=(a[i]=='1');
    }

    P("NO");

}


#include <iostream>
#include <string.h>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <limits.h>
#include <vector>
#include <string>
#include <ctype.h>
#include <complex>
#include <cmath>
using namespace             std;
const int                   Maxn=3000,Maxm=2500000,Mo=1000000007,oo=INT_MAX>>2;
int                         n,m,ans,i,j,
a[Maxn],b[Maxn],sa[Maxn],sb[Maxn],vis[Maxn][Maxn],f[Maxn][Maxn];
double                      sumxf,xf[Maxn];
string                      s1,s2;
int dfs(int l,int r)
{
    if (vis[l][r]) return f[l][r];
    if (l==n) return f[l][r]=(a[l]==b[r]);
    if (r==m) return 0;
    vis[l][r]=1;
    int p=dfs(l+1,r+1);
    if (p>0&&a[l]==b[r]) f[l][r]=p+1;
    return f[l][r];
}
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.in","r",stdin);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.out","w",stdout);
    cin>>s1>>s2;
    n=s1.size();
    m=s2.size();
    for (int i=1;i<=n;i++) sa[i]=a[i]=s1[i-1]-'0';
    for (int i=1;i<=m;i++) sb[i]=b[i]=s2[i-1]-'0';
    for (int i=2;i<=n;i++) sa[i]+=sa[i-1];
    for (int i=2;i<=m;i++) sb[i]+=sb[i-1];

    for (i=1;i<=n;i++)
        dfs(i,1);
    int ck=0;
    //cout<<f[n][1]<<endl;
    for (i=1;i<=n+1;i++)
    {
        if (f[i][1]==n-i+1)
        {
                int c1=sa[i-1];
                int c2=sb[m]-sb[n-i+1];
                if (n-i+1<m&&b[n-i+2]==0&&sa[n]%2==1) c1--;
                if (n-i+1<m&&b[n-i+2]==1&&sa[n]%2==1) c1++;
                if (c1>=c2) ck=1;
        }
    }
    if(ck) cout<<"YES\n"; else cout<<"NO\n";

}


#include <iostream>
#include <string.h>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <limits.h>
#include <vector>
#include <string>
#include <ctype.h>
#include <complex>
#include <cmath>
using namespace             std;
const int                   Maxn=3000,Maxm=2500000,Mo=1000000007,oo=INT_MAX>>2;
int                         n,m,ans,i,j,a[Maxn],b[Maxn],sa[Maxn],sb[Maxn],nt[Maxn],rd0,ar0;
double                      sumxf,xf[Maxn];
string                      s1,s2;
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.in","r",stdin);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.out","w",stdout);
    cin>>s1>>s2;
    int n=s1.size();
    int m=s2.size();
    for (int i=1;i<=n;i++) a[i]=s1[i-1]-'0';
    for (int i=1;i<=m;i++) b[i]=s2[i-1]-'0';
    for (int i=2;i<=n;i++) sa[i]+=a[i-1];
    for (int i=2;i<=m;i++) sb[i]+=b[i-1];
    nt[1]=0;
    for (int i=2;i<=n;i++)
    {
        while (j&&a[j+1]!=a[i]) j=nt[j];
        if (a[j+1]==a[i]) j++;
        nt[i]=j;
    }
    int ck=0;
    for (i=1;i<=n;i++)
    {
        int k=1;
        for (j=1;j<=m;j++){
            while (k>=i+1&&b[k+1]!=a[j]) k=nt[k];
            if (k<i-1) k=i-1;
            if (b[k+1]==a[j]) k++;
            if (k==m)
            {
                k=nt[k]; if (k<i-1) k=i-1;
                int c1=sa[i-1];
                int c2=sb[m]-sb[n-i+1];
                if (n-i+1<m&&b[n-i+2]==0&&sa[n]%2==1) c1--;
                if (n-i+1<m&&b[n-i+2]==1&&sa[n]%2==1) c1++;
                if (c1>=c2) ck=1;
            }
        }
    }
    if(ck) cout<<"YES\n"; else cout<<"NO\n";

}


#include <iostream>
#include <string.h>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <limits.h>
#include <vector>
#include <string>
#include <ctype.h>
#include <complex>
#include <cmath>
using namespace             std;
const int                   Maxn=3000,Maxm=2500000,Mo=1000000007,oo=INT_MAX>>2;
int                         n,m,ans,i,j,a[Maxn],b[Maxn],sa[Maxn],sb[Maxn],nt[Maxn],rd0,ar0;
double                      sumxf,xf[Maxn];
string                      s1,s2;
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);
    cin>>s1>>s2;
    int n=s1.size();
    int m=s2.size();
    for (int i=1;i<=n;i++) sa[i]=a[i]=s1[i-1]-'0';
    for (int i=1;i<=m;i++) sb[i]=b[i]=s2[i-1]-'0';
    for (int i=2;i<=n;i++) sa[i]+=sa[i-1];
    for (int i=2;i<=m;i++) sb[i]+=sb[i-1];
    nt[1]=0;
    for (int i=2;i<=n;i++)
    {
        while (j&&a[j+1]!=a[i]) j=nt[j];
        if (a[j+1]==a[i]) j++;
        nt[i]=j;
    }
    int ck=0;
    for (i=1;i<=n;i++)
    {
        int k=i-1;
        for (j=1;j<=m;j++){
            while (k>=i&&b[j]!=a[k+1]) k=nt[k];
            if (k<i-1) k=i-1;
            if (b[j]==a[k+1]) k++;
            if (k==n)
            {
                k=nt[k]; if (k<i-1) k=i-1;
                int c1=sa[i-1];
                int c2=sb[m]-sb[n-i+1];
                if (n-i+1<m&&b[n-i+2]==0&&sa[n]%2==1) c1--;
                if (n-i+1<m&&b[n-i+2]==1&&sa[n]%2==1) c1++;
                if (c1>=c2) ck=1;
            }
        }
    }
    if(ck) cout<<"YES\n"; else cout<<"NO\n";

}


#include <iostream>
#include <string.h>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <limits.h>
#include <vector>
#include <string>
#include <ctype.h>
#include <complex>
#include <cmath>
using namespace             std;
const int                   Maxn=3000,Maxm=2500000,Mo=1000000007,oo=INT_MAX>>2;
int                         n,m,ans,i,j,a[Maxn],b[Maxn],sa[Maxn],sb[Maxn],nt[Maxn],rd0,ar0;
double                      sumxf,xf[Maxn];
string                      s1,s2;
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.in","r",stdin);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.out","w",stdout);
    cin>>s1>>s2;
    int n=s1.size();
    int m=s2.size();
    for (int i=1;i<=n;i++) sa[i]=a[i]=s1[i-1]-'0';
    for (int i=1;i<=m;i++) sb[i]=b[i]=s2[i-1]-'0';
    for (int i=2;i<=n;i++) sa[i]+=sa[i-1];
    for (int i=2;i<=m;i++) sb[i]+=sb[i-1];
    nt[1]=0;
    for (int i=2;i<=n;i++)
    {
        while (j&&a[j+1]!=a[i]) j=nt[j];
        if (a[j+1]==a[i]) j++;
        nt[i]=j;
    }
    int ck=0;
    for (i=1;i<=n;i++)
    {
        int k=i-1;
        for (j=1;j<=m;j++){
            while (k>=i&&b[j]!=a[k+1]) k=nt[k];
            if (k<i-1) k=i-1;
            if (b[j]==a[k+1]) k++;
            if (k==n-i+1)
            {
                k=nt[k]; if (k<i-1) k=i-1;
                int c1=sa[i-1];
                int c2=sb[m]-sb[n-i+1];
                if (n-i+1<m&&b[n-i+2]==0&&sa[n]%2==1) c1--;
                if (n-i+1<m&&b[n-i+2]==1&&sa[n]%2==1) c1++;
                if (c1>=c2) ck=1;
            }
        }
    }
    if(ck) cout<<"YES\n"; else cout<<"NO\n";

}


#include <iostream>
#include <string.h>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <limits.h>
#include <vector>
#include <string>
#include <ctype.h>
#include <complex>
#include <cmath>
using namespace             std;
const int                   Maxn=3000,Maxm=2500000,Mo=1000000007,oo=INT_MAX>>2;
int                         n,m,ans,i,j,
a[Maxn],b[Maxn],sa[Maxn],sb[Maxn],vis[Maxn][Maxn],f[Maxn][Maxn];
double                      sumxf,xf[Maxn];
string                      s1,s2;
int dfs(int l,int r)
{
    if (vis[l][r]) return f[l][r];
    if (l==n) return f[l][r]=(a[l]==b[r]);
    if (r==m) return 0;
    vis[l][r]=1;
    int p=dfs(l+1,r+1);
    if (p>0&&a[l]==b[r]) f[l][r]=p+1;
    return f[l][r];
}
map<int, int> mp;
int main()
{
    ios::sync_with_stdio(0);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.in","r",stdin);
    //freopen("/Users/MAC/Desktop/Error202/Error202/1.out","w",stdout);
    cin>>s1>>s2;
    n=s1.size();
    m=s2.size();
    for (int i=1;i<=n;i++) sa[i]=a[i]=s1[i-1]-'0';
    for (int i=1;i<=m;i++) sb[i]=b[i]=s2[i-1]-'0';
    for (int i=2;i<=n;i++) sa[i]+=sa[i-1];
    for (int i=2;i<=m;i++) sb[i]+=sb[i-1];
    if (sb[n]%2==1) {
        b[++n]=1; sb[n]=sb[n-1]+1;
    }

    for (i=1;i<=n;i++)
        dfs(i,1);
    int ck=0;
    //cout<<f[n][1]<<endl;
    for (i=1;i<=n+1;i++)
    {
        if (f[i][1]==n-i+1)
        {
                int c1=sa[i-1];
                int c2=sb[m]-sb[n-i+1];
                if (n-i+1<m&&b[n-i+2]==0&&sa[n]%2==1) c1--;
                if (n-i+1<m&&b[n-i+2]==1&&sa[n]%2==1) c1++;
                if (c1>=c2) ck=1;
        }
    }
    if(ck) cout<<"YES\n"; else cout<<"NO\n";

}