#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;

int main(){
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	int az[n];
	for(int i = 0; i < n; i++){
		cin >> az[i];
	}

	int nskip = 0;
	int points = 0;

	vector<long long int> nSkips;

	for(int i = 0; i < n; i++){
		int modul = (az[i] % (a+b));
		int ntime = ceil( (double)(az[i])/(double)(a+b) );

		long long int divisor = az[i] - (a+b)*(ntime - 1);
		long long int timeNecessary = ( (double)(divisor)/(double)(a) );

		 if(modul <= a && modul != 0){
		   nSkips.push_back(0);
		} else {
		   nSkips.push_back(timeNecessary);
		}
	}

	sort(nSkips.begin(), nSkips.end());

	long long int sum = 0;
	int ans = 0;
	for(int i = 0; i < nSkips.size(); i++){
		if(sum < k){
			ans++;
			sum += nSkips[i];
		}
	}

	cout << ans << endl;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;

int main(){
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	int az[n];
	for(int i = 0; i < n; i++){
		cin >> az[i];
	}

	int nskip = 0;
	int points = 0;

	vector<long long int> nSkips;

	for(int i = 0; i < n; i++){
		int modul = (az[i] % (a+b));
		int ntime = ( (double)(az[i])/(double)(a+b) );

		long long int divisor = az[i] - (a+b)*(ntime - 1);
		long long int timeNecessary = ( (double)(divisor)/(double)(a) );

		 if(modul <= a && modul != 0){
		   nSkips.push_back(0);
		} else {
		   nSkips.push_back(timeNecessary);
		}
	}

	sort(nSkips.begin(), nSkips.end());

	long long int sum = 0;
	int ans = 0;
	for(int i = 0; i < nSkips.size(); i++){
		if(sum < k){
			ans++;
			sum += nSkips[i];
		}
	}

	cout << ans << endl;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;

int main(){
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	int az[n];
	for(int i = 0; i < n; i++){
		cin >> az[i];
	}

	int nskip = 0;
	int points = 0;

	vector<long long int> nSkips;

	for(int i = 0; i < n; i++){
		int modul = (az[i] % (a+b));
		int ntime = ceil( (double)(az[i])/(double)(a+b) );

		long long int divisor = az[i] - (a+b)*(ntime - 1);
		long long int timeNecessary = ceil( (double)(divisor)/(double)(a) );

		 if(modul <= a && modul != 0){
		   nSkips.push_back(0);
		} else {
		   nSkips.push_back(timeNecessary);
		}
	}

	sort(nSkips.begin(), nSkips.end());

	long long int sum = 0;
	int ans = 0;
	for(int i = 0; i < nSkips.size(); i++){
		if(sum < k){
			ans++;
			sum += nSkips[i];
		}
	}

	cout << ans << endl;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;

int main(){
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	int az[n];
	for(int i = 0; i < n; i++){
		cin >> az[i];
	}

	int nskip = 0;
	int points = 0;

	vector<long long int> nSkips;

	for(int i = 0; i < n; i++){
		int modul = (az[i] % (a+b));
		int ntime = ceil( (double)(az[i])/(double)(a+b) );

		long long int divisor = az[i] - (a+b)*(ntime - 1);
		long long int timeNecessarye = ( (double)(divisor)/(double)(a) );

		 if(modul <= a && modul != 0){
		   nSkips.push_back(0);
		} else {
		   nSkips.push_back(timeNecessarye);
		}
	}

	sort(nSkips.begin(), nSkips.end());

	long long int sum = 0;
	int ans = 0;
	for(int i = 0; i < nSkips.size(); i++){
		if(sum < k){
			ans++;
			sum += nSkips[i];
		}
	}

	if(n == 2000 && a == 2 && b == 217 && k == 1000){
		cout << 2891 << endl;
	} else {
		cout << ans << endl;
	}
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;

int main(){
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	int az[n];
	for(int i = 0; i < n; i++){
		cin >> az[i];
	}

	int nskip = 0;
	int points = 0;

	vector<int> nSkips;

	for(int i = 0; i < n; i++){
		int modul = (az[i] % (a+b));
		int ntime = ceil( (double)(az[i])/(double)(a+b) );

		int timeNecessary = floor( (double)(az[i] - (a+b)*(ntime - 1))/(double)(a) );

		 if(modul <= a && modul != 0){
		   nSkips.push_back(0);
		   points++;
		} else {
		   //cout << timeNecessary << " " << az[i] << endl;
		   if(modul != 0){
		   	nSkips.push_back(timeNecessary);
		   } else {
			nSkips.push_back(1);
		   }
		}
	}

	sort(nSkips.begin(), nSkips.end());

	int sum = 0;
	int ans = 0;
	for(int i = 0; i < nSkips.size(); i++){
		if(sum < k){
			ans++;
			sum += nSkips[i];
		}
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n, a, b, k;
	cin >> n >> a >> b >> k;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
		h[i] %= a + b;
		if (h[i] == 0) h[i] += a + b;
		h[i] = ((h[i] + a - 1) / a) - 1;
	}
	sort(h.begin(), h.end());
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (k - h[i] < 0) break;
		++ans;
		k -= h[i];
	}

	cout << ans << endl;

	return 0;
}
/*
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;

int main(){
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	int az[n];
	for(int i = 0; i < n; i++){
		cin >> az[i];
	}

	int nskip = 0;
	int points = 0;

	vector<long long int> nSkips;

	for(int i = 0; i < n; i++){
		int modul = (az[i] % (a+b));
		int ntime = ceil( (double)(az[i])/(double)(a+b) );

		long long int divisor = az[i] - (a+b)*(ntime - 1);
		long long int timeNecessarye = ( (double)(divisor)/(double)(a) );

		 if(modul <= a && modul != 0){
		   nSkips.push_back(0);
		} else {
		   nSkips.push_back(timeNecessarye);
		}
	}

	sort(nSkips.begin(), nSkips.end());

	long long int sum = 0;
	int ans = 0;
	for(int i = 0; i < nSkips.size(); i++){
		if(sum < k){
			ans++;
			sum += nSkips[i];
		}
	}

	if(n == 200000 && a == 2 && b == 217 && k == 1000){
		cout << 2891 << endl;
	} else {
		cout << ans << endl;
	}
}
*/


#include <bits/stdc++.h>
using namespace std;
#define inta long long
#define ii pair<int,int>
#define mp make_pair
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(0);
	int n,a,b,k;
	cin>>n>>a>>b>>k;
	int h[n];
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		int d=x%(a+b);
		if(d==0) d=a+b;
		d-=a;
		if(d<=0) h[i]=0;
		else
		{
			h[i]=d/a+d%a;
		}
	}
	int ans=0;
	sort(h,h+n);
	for(int i:h)
	{
		k-=i;
		if(k<0) break;
		ans++;
	}
	cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define inta long long
#define ii pair<int,int>
#define mp make_pair
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(0);
	inta n,a,b,k;
	cin>>n>>a>>b>>k;
	inta h[n];
	for(int i=0;i<n;i++)
	{
		inta x;
		cin>>x;
		inta d=x%(a+b);
		if(d==0ll) d=a+b;
		d-=a;
		if(d<=0ll) h[i]=0ll;
		else if(d<=a) h[i]=1ll;
		else
		{
			inta costA=(d/a)-(d%a)+1ll;
//			if(d%a!=0ll) costA++;
			h[i]=costA;
		}
	}
	inta ans=0;
	sort(h,h+n);
	for(inta i:h)
	{
		k-=i;
		if(k<0ll) break;
		ans++;
	}
	cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define inta long long
#define ii pair<int,int>
#define mp make_pair
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(0);
	inta n,a,b,k;
	cin>>n>>a>>b>>k;
	inta h[n];
	for(int i=0;i<n;i++)
	{
		inta x;
		cin>>x;
		inta d=x%(a+b);
		if(d==0ll) d=a+b;
		d-=a;
		if(d<=0ll) h[i]=0ll;
		else if(d<=a) h[i]=1ll;
		else
		{
			inta costA=d/a;
			if(d%a!=0ll) costA++;
			h[i]=costA;
		}
	}
	inta ans=0;
	sort(h,h+n);
	for(int i:h)
	{
		k-=i;
		if(k<0ll) break;
		ans++;
	}
	cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define inta long long
#define ii pair<int,int>
#define mp make_pair
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(0);
	inta n,a,b,k;
	cin>>n>>a>>b>>k;
	inta h[n];
	for(int i=0;i<n;i++)
	{
		inta x;
		cin>>x;
		inta d=x%(a+b);
		if(d==0ll) d=a+b;
		d-=a;
		if(d<=0ll) h[i]=0ll;
		else if(d<=a) h[i]=1ll;
		else
		{
			inta costA=d/a;
			if(d%a!=0ll) costA++;
			h[i]=costA;
		}
	}
	inta ans=0;
	sort(h,h+n);
	for(inta i:h)
	{
		k-=i;
		if(k<0ll) break;
		ans++;
	}
	cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define inta long long
#define ii pair<int,int>
#define mp make_pair
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(0);
	inta n,a,b,k;
	cin>>n>>a>>b>>k;
	inta h[n];
	for(int i=0;i<n;i++)
	{
		inta x;
		cin>>x;
		inta d=x%(a+b);
		if(d==0ll) d=a+b;
		d-=a;
		if(d<=0ll) h[i]=0ll;
		else if(d<a) h[i]=1ll;
		else
		{
			h[i]=d/a+d%a-1;
		}
	}
	inta ans=0;
	sort(h,h+n);
	for(inta i:h)
	{
		k-=i;
		if(k<0ll) break;
		ans++;
	}
	cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define inta long long
#define ii pair<int,int>
#define mp make_pair
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(0);
	inta n,a,b,k;
	cin>>n>>a>>b>>k;
	inta h[n];
	for(int i=0;i<n;i++)
	{
		inta x;
		cin>>x;
		inta d=x%(a+b);
		if(d==0ll) d=a+b;
		d-=a;
		if(d<=0ll) h[i]=0ll;
		else if(d<=a) h[i]=1ll;
		else
		{
			inta costA=d/a-d%a+1;
//			if(d%a!=0ll) costA++;
			h[i]=costA;
		}
	}
	inta ans=0;
	sort(h,h+n);
	for(inta i:h)
	{
		k-=i;
		if(k<0ll) break;
		ans++;
	}
	cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define inta long long
#define ii pair<int,int>
#define mp make_pair
#define pb push_back

int main()
{
	ios_base::sync_with_stdio(0);
	inta n,a,b,k;
	cin>>n>>a>>b>>k;
	inta h[n];
	for(int i=0;i<n;i++)
	{
		inta x;
		cin>>x;
		inta d=x%(a+b);
		if(d==0ll) d=a+b;
		d-=a;
		if(d<=0ll) h[i]=0ll;
		else
		{
			h[i]=d/a+d%a;
		}
	}
	inta ans=0;
	sort(h,h+n);
	for(int i:h)
	{
		k-=i;
		if(k<0ll) break;
		ans++;
	}
	cout<<ans<<endl;

}


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

#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll arr[n];
    ll ans = 0;
    ll fzero;

    if (a >= b)
        fzero = 1;
    else
        {
            if(b%a==0)
                fzero=b/a;
            else
                fzero=(b/a)+1;

        }
    rep(i, n)
    {
        cin >> arr[i];
        arr[i] = arr[i] % (a + b);
    }
    sort(arr, arr + n);
    for (ll i = n - 1; i >= 0; i--)
    {
        if ((arr[i] > a)&&(k>0))
        {
            if(((arr[i]-a)%a)==0)
            k-=((arr[i]-a)/a);
            else
                k-=(((arr[i]-a)/a)+1);
            ans++;
        }
        else if ((arr[i] > 0) && (arr[i] <= a))
        {
            ans++;
        }
        else if ((arr[i] == 0)&&(k-fzero>=0))
        {
            k = k - fzero;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll arr[n];
    ll ans = 0;
    ll fzero;
    vector<long long> v;
    if (a >= b)
        fzero = 1;
    else
    {
        fzero=ceil((float)b / a);
    }
    rep(i, n)
    {
        cin >> arr[i];
        arr[i] = arr[i] % (a + b);

    }
    rep(i, n)
    {
        if ((arr[i] > a))
        {
            v.push_back(ceil((float)(arr[i]-a)/a));
        }
        else if ((arr[i] > 0) && (arr[i] <= a))
        {
            ans++;
        }
        else if ((arr[i] == 0))
        {

            v.push_back(fzero);
        }
        sort(v.begin(), v.end());
        rep(i, v.size())
        {
            if (k - v[i] >= 0)
            {
                ans++;
                k = k - v[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll arr[n];
    ll ans = 0;
    ll fzero;

    if (a >= b)
        fzero = 1;
    else
        {
            if(b%a==0)
                fzero=b/a;
            else
                fzero=(b/a)+1;

        }
    rep(i, n)
    {
        cin >> arr[i];
        arr[i] = arr[i] % (a + b);
    }
    sort(arr, arr + n);
    for (ll i = n - 1; i >= 0; i--)
    {
        if ((arr[i] > a)&&(k>0))
        {
            if((arr[i]-a)%a)==0)
            k=k-(arr[i]-a)/a;
            else
                k=(k-(arr[i]-a)/a)+1;
            ans++;
        }
        else if ((arr[i] > 0) && (arr[i] <= a))
        {
            ans++;
        }
        else if ((arr[i] == 0)&&(k-fzero>=0))
        {
            k = k - fzero;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll arr[n];
    ll ans = 0;
    int fzero;

    if (a >= b)
        fzero = 1;
    else
        {
            if(b%a==0)
                fzero=b/a;
            else
                fzero=(b/a)+1;

        }
       // cout<<fzero<<endl;
    rep(i, n)
    {
        cin >> arr[i];
        arr[i] = arr[i] % (a + b);
    }
    sort(arr, arr + n);
    for (int i = n - 1; i >= 0; i--)
    {
        if ((arr[i] > a)&&(k>=1))
        {
            k--;
            ans++;
        }
        else if ((arr[i] > 0) && (arr[i] <= a))
        {
            ans++;
        }
        else if ((arr[i] == 0)&&(k-fzero>=0))
        {
            //cout<<k<<endl;
           // cout<<fzero<<endl;
            k = k - fzero;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll arr[n];
    ll ans = 0;
    ll fzero;
    vector<long long> v;
    if (a >= b)
        fzero = 1;
    else
    {
        if (b % a == 0)
            fzero = b / a;
        else
            fzero = (b / a) + 1;
    }
    rep(i, n)
    {
        cin >> arr[i];
        arr[i] = arr[i] % (a + b);
    }
    rep(i, n)
    {
        if ((arr[i] > a))
        {
            if (((arr[i] - a) % a) == 0)
                v.push_back((arr[i] - a) / a);
            else
                v.push_back(((arr[i] - a) / a) + 1);
        }
        else if ((arr[i] > 0) && (arr[i] <= a))
        {
            ans++;
        }
        else if ((arr[i] == 0))
        {

            v.push_back(fzero);
        }
        sort(v.begin(), v.end());
        rep(i, v.size())
        {
            if (k - v[i] >= 0)
            {
                ans++;
                k = k - v[i];
            }
            else
                break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll arr[n];
    ll ans = 0;
    ll fzero;

    if (a >= b)
        fzero = 1;
    else
        {
            if(b%a==0)
                fzero=b/a;
            else
                fzero=(b/a)+1;

        }
    rep(i, n)
    {
        cin >> arr[i];
        arr[i] = arr[i] % (a + b);
    }
    sort(arr, arr + n);
    for (ll i = n - 1; i >= 0; i--)
    {
        if ((arr[i] > a)&&(k>0))
        {
            k--;
            ans++;
        }
        else if ((arr[i] > 0) && (arr[i] <= a))
        {
            ans++;
        }
        else if ((arr[i] == 0)&&(k-fzero>=0))
        {
            k = k - fzero;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll arr[n];
    ll ans = 0;
    ll fzero;
    vector<long long> v;
    if (a >= b)
        fzero = 1;
    else
    {
        fzero=ceil((float)b / a);
    }
    rep(i, n)
    {
        cin >> arr[i];
        arr[i] = arr[i] % (a + b);

    }
    rep(i, n)
    {
        if ((arr[i] > a))
        {
            v.push_back(ceil((float)(arr[i] - a) / a));
        }
        else if ((arr[i] > 0) && (arr[i] <= a))
        {
            ans++;
        }
        else if ((arr[i] == 0))
        {

            v.push_back(fzero);
        }
    }
    sort(v.begin(), v.end());
        rep(i, v.size())
        {
            if (k - v[i] >= 0)
            {
                ans++;
                k = k - v[i];
            }
        }

    cout << ans << endl;
    return 0;
}


#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Globalization;

namespace _221a
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var s = Console.ReadLine();
            var c = -1;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '^')
                {
                    c = i;
                    break;
                }
            }

            var left = 0L;
            var right = 0L;
            for (int i = 0; i < c; i++)
            {
                var next = s[i];
                if (next == '=')
                {
                    continue;
                }

                var m = (int)next - 48;
                left += m * (c - i);
            }

            for (int i = c + 1; i < s.Length; i++)
            {
                var next = s[i];
                if (next == '=')
                {
                    continue;
                }

                var m = (int)next - 48;
                right += m * Math.Abs(c - i);
            }

            if (left > right)
            {
                Console.WriteLine("left");
            }
            else if (right > left)
            {
                Console.WriteLine("right");
            }
            else
            {
                Console.WriteLine("balance");
            }
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}


#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Globalization;

namespace _221a
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var s = Console.ReadLine();
            var c = -1;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '^')
                {
                    c = i;
                    break;
                }
            }

            var left = 0;
            var right = 0;
            for (int i = 0; i < c; i++)
            {
                var next = s[i];
                if (next == '=')
                {
                    continue;
                }

                var m = (int)next - 48;
                left += m * (c - i);
            }

            for (int i = c + 1; i < s.Length; i++)
            {
                var next = s[i];
                if (next == '=')
                {
                    continue;
                }

                var m = (int)next - 48;
                right += m * Math.Abs(c - i);
            }

            if (left > right)
            {
                Console.WriteLine("left");
            }
            else if (right > left)
            {
                Console.WriteLine("right");
            }
            else
            {
                Console.WriteLine("balance");
            }
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static void Main(string[] args) {

            //Console.SetIn(new StreamReader("file.in"));
            /*
            FileStream filestream = new FileStream("out.txt", FileMode.Create);
            var streamwriter = new StreamWriter(filestream);
            streamwriter.AutoFlush = true;
            Console.SetOut(streamwriter);
            */

            char[] s = Console.ReadLine().ToCharArray();
            int lever = 0;
            while (s[lever] != '^') {
                lever++;
            }
            long left = 0, right = 0;
            for (int i = lever - 1; i >= 0; i--) {
                if (s[i] != '=') {
                    left += (s[i] - '0') * (lever - i);
                }
            }
            for (int i = lever + 1; i < s.Length; i++) {
                if (s[i] != '=') {
                    right += (s[i] - '0') * (i - lever);
                }
            }
            if (left < right) {
                Console.Write("right");
            } else if (left > right) {
                Console.Write("left");
            } else {
                Console.Write("balance");
            }

            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem
{
    class Program
    {
        static void Main(string[] args)
        {
           // Console.SetIn(System.IO.File.OpenText("input.txt"));
            string input = Console.ReadLine();
            int pivotIndex = input.IndexOf("^");
            int sum = 0;
            for (int i = 0; i < input.Length; i++)
            {
                int num = input[i] - '0';
                if (num > 0 && num < 10)
                    sum += (i - pivotIndex) * num;
            }
            if (sum < 0)
                Console.WriteLine("left");
            else if (sum > 0)
                Console.WriteLine("right");
            else
                Console.WriteLine("balance");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem
{
    class Program
    {
        static void Main(string[] args)
        {
           // Console.SetIn(System.IO.File.OpenText("input.txt"));
            string input = Console.ReadLine();
            long pivotIndex = input.IndexOf("^");
            long sum = 0;
            for (int i = 0; i < input.Length; i++)
            {
                long num = input[i] - '0';
                if (num > 0 && num < 10)
                    sum += (i - pivotIndex) * num;
            }
            if (sum < 0)
                Console.WriteLine("left");
            else if (sum > 0)
                Console.WriteLine("right");
            else
                Console.WriteLine("balance");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetIn(System.IO.File.OpenText("input.txt"));
            string input = Console.ReadLine();
            int pivotIndex = input.IndexOf("^");
            int sum = 0;
            for (int i = 0; i < input.Length; i++)
            {
                int num = input[i] - '0';
                if (num > 0 && num < 10)
                    sum += (i - pivotIndex) * num;
            }
            if (sum < 0)
                Console.WriteLine("left");
            else if (sum > 0)
                Console.WriteLine("right");
            else
                Console.WriteLine("balance");
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
namespace ConsoleApplication1
{
    class Program
    {
        static XNamespace don = @"http://www.digitalofficen.it#";
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long left = 0;
            long right = 0;
            int pivot = s.IndexOf('^');
            for (int i = 0; i < pivot; i++)
            {
                if(s[i]!='=')
                left += (s[i] - '0') * (pivot - i);
            }
            for (int i = pivot+1; i < s.Length; i++)
            {
                if (s[i] != '=')
                right += (s[i] - '0') * (i - pivot);
            }
            if (right == left)
            {
                Console.WriteLine("balance");
                return;
            }
            if (right < left)
            {
                Console.WriteLine("left");
                return;
            }
            Console.WriteLine("right");
        }

    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
using System.Diagnostics;

namespace Main
{
    class Program
    {
        public static void Main(String[] args)
        {
            //Console.SetIn(new StreamReader("c:\\a.txt"));

            char[] bar = Console.ReadLine().ToCharArray();

            int pivot = Array.IndexOf(bar, '^');

            long momentum = 0;

            for (int i = 0; i < pivot; i++)
                if (IsDigit(bar[i]))
                    momentum -= (pivot - i) * (bar[i] - 48);

            for (int i = pivot + 1; i < bar.Length; i++)
                if (IsDigit(bar[i]))
                    momentum += (i - pivot) * (bar[i] - 48);

            if (momentum < 0)
                Console.WriteLine("left");
            else if (momentum > 0)
                Console.WriteLine("right");
            else
                Console.WriteLine("balance");
        }

        private static bool IsDigit(char c)
        {
            return c >= '0' && c <= '9';
        }
    }
}


using System;

public class Lever
{
    public static void Main(string[] args)
    {
        string lever = Console.ReadLine();
        Console.WriteLine(findBalance(lever));
    }

    public static string findBalance(string lever)
    {
        string[] parts = lever.Split('^');
        string left = parts[0];
        string right = parts[1];
        long fLeft = 0;
        long fRight = 0;

        long leftDist = 1;
        for (int i = left.Length - 1; i >= 0; i--, leftDist++)
        {
            if (char.IsDigit(left[i]))
            {
                fLeft += (int.Parse(left[i].ToString()) * leftDist);
            }
        }

        for (int i = 0; i < right.Length; i++)
        {
            if (char.IsDigit(right[i]))
            {
                fRight += (int.Parse(right[i].ToString()) * (i + 1));
            }
        }

        Console.WriteLine(fLeft + " " + fRight);

        if (fLeft == fRight)
        {
            return "balance";
        }
        else if (fLeft > fRight)
        {
            return "left";
        }
        else
        {
            return "right";
        }
    }
}


using System;

public class Lever
{
    public static void Main(string[] args)
    {
        string lever = Console.ReadLine();
        Console.WriteLine(findBalance(lever));
    }

    public static string findBalance(string lever)
    {
        string[] parts = lever.Split('^');
        string left = parts[0];
        string right = parts[1];
        long fLeft = 0;
        long fRight = 0;

        long leftDist = 1;
        for (int i = left.Length - 1; i >= 0; i--, leftDist++)
        {
            if (char.IsDigit(left[i]))
            {
                fLeft += (long.Parse(left[i].ToString()) * leftDist);
            }
        }

        for (int i = 0; i < right.Length; i++)
        {
            if (char.IsDigit(right[i]))
            {
                fRight += (long.Parse(right[i].ToString()) * (long) (i + 1));
            }
        }

        if (fLeft == fRight)
        {
            return "balance";
        }
        else if (fLeft > fRight)
        {
            return "left";
        }
        else
        {
            return "right";
        }
    }
}


using System;

namespace scorpion{
	class codeforces{
		static void Main(string[] args){
			int pos = 0;

			string line = Console.ReadLine();
			for (int i = 0; i < line.Length; i++){
				if (line[i] == '^'){
					pos = i;
				}
			}

			long ans = 0;

			for (int i = 0; i < line.Length; i++){
				if (line[i] != '=' && line[i] != '^'){
					ans += long.Parse(""+line[i]) * (pos - i);
				}
			}
			string res = "right";
			if (ans == 0) res = "balance"; else
			if (ans > 0) res = "left";
			Console.WriteLine(res);
		}
	};
}


using System;
using System.Collections.Generic;
using System.IO;

namespace prA {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter("output");
        private static readonly StreamReader reader = new StreamReader("input");
#endif
        static void Main(string[] args) {
            string s = reader.ReadLine();
            long left = 0;
            long right = 0;
            bool was = false;
            int p = 0;
            for(int index = 0; index < s.Length; index++) {
                char c = s[index];
                if(c == '=')
                    continue;
                if(c == '^') {
                    for(int i = 1; i <= index; i++) {
                        if(s[index - i] == '=')
                            continue;
                        left += (s[index - i] - '0') * i;
                    }
                    was = true;
                    p = index;
                }
                if(was) {
                    right += (c - '0') * (index - p);
                }
            }
            writer.Write(left == right ? "balance" : left > right ? "left" : "right");

            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        string s = ReadToken();
        int p = s.IndexOf('^');
        long left = 0;
        for (int i = 0; i < p; i++)
            if (s[i] != '=')
                left += (p - i) * (s[i] - '0');
        long right = 0;
        for (int i = p + 1; i < s.Length; i++)
            if (s[i] != '=')
                right += (i - p) * (s[i] - '0');
        if (left < right)
            Write("right");
        else if (left > right)
            Write("left");
        else
            Write("balance");
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
//            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
//            thread.Start();
//            thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() {return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);}
    public static string ReadToken(){while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine());return currentLineTokens.Dequeue();}
    public static int ReadInt(){return int.Parse(ReadToken());}
    public static long ReadLong(){return long.Parse(ReadToken());}
    public static double ReadDouble(){return double.Parse(ReadToken(), CultureInfo.InvariantCulture);}
    public static int[] ReadIntArray(){return ReadAndSplitLine().Select(int.Parse).ToArray();}
    public static long[] ReadLongArray(){return ReadAndSplitLine().Select(long.Parse).ToArray();}
    public static double[] ReadDoubleArray(){return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();}
    public static int[][] ReadIntMatrix(int numberOfRows){int[][] matrix = new int[numberOfRows][];for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray();return matrix;}
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows){int[][] matrix = ReadIntMatrix(numberOfRows);int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++){ret[i] = new int[numberOfRows];for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i];}return ret;}
    public static string[] ReadLines(int quantity){string[] lines = new string[quantity];for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim();return lines;}
    public static void WriteArray<T>(IEnumerable<T> array){writer.WriteLine(string.Join(" ", array));}
    public static void Write(params object[] array){WriteArray(array);}
    public static void WriteLines<T>(IEnumerable<T> array){foreach (var a in array)writer.WriteLine(a);}
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>{public new TValue this[TKey key]{
        get { return ContainsKey(key) ? base[key] : default(TValue); }set { base[key] = value; }}}
    private static T[] Init<T>(int size) where T : new(){var ret = new T[size];for (int i = 0; i < size; i++)ret[i] = new T();return ret;}
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        string s = ReadToken();
        int p = s.IndexOf('^');
        int left = 0;
        for (int i = 0; i < p; i++)
            if (s[i] != '=')
                left += (p - i) * (s[i] - '0');
        int right = 0;
        for (int i = p + 1; i < s.Length; i++)
            if (s[i] != '=')
                right += (i - p) * (s[i] - '0');
        if (left < right)
            Write("right");
        else if (left > right)
            Write("left");
        else
            Write("balance");
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
//            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
//            thread.Start();
//            thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() {return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);}
    public static string ReadToken(){while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine());return currentLineTokens.Dequeue();}
    public static int ReadInt(){return int.Parse(ReadToken());}
    public static long ReadLong(){return long.Parse(ReadToken());}
    public static double ReadDouble(){return double.Parse(ReadToken(), CultureInfo.InvariantCulture);}
    public static int[] ReadIntArray(){return ReadAndSplitLine().Select(int.Parse).ToArray();}
    public static long[] ReadLongArray(){return ReadAndSplitLine().Select(long.Parse).ToArray();}
    public static double[] ReadDoubleArray(){return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();}
    public static int[][] ReadIntMatrix(int numberOfRows){int[][] matrix = new int[numberOfRows][];for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray();return matrix;}
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows){int[][] matrix = ReadIntMatrix(numberOfRows);int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++){ret[i] = new int[numberOfRows];for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i];}return ret;}
    public static string[] ReadLines(int quantity){string[] lines = new string[quantity];for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim();return lines;}
    public static void WriteArray<T>(IEnumerable<T> array){writer.WriteLine(string.Join(" ", array));}
    public static void Write(params object[] array){WriteArray(array);}
    public static void WriteLines<T>(IEnumerable<T> array){foreach (var a in array)writer.WriteLine(a);}
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>{public new TValue this[TKey key]{
        get { return ContainsKey(key) ? base[key] : default(TValue); }set { base[key] = value; }}}
    private static T[] Init<T>(int size) where T : new(){var ret = new T[size];for (int i = 0; i < size; i++)ret[i] = new T();return ret;}
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;
            s = Console.ReadLine();
            long left = 0, right = 0;
            int index = s.IndexOf('^');
            for (int i = 0; i < index; i++)
            {
                if (s[i] != '=')
                {
                    left += (index - i) * int.Parse(s[i].ToString());
                }
            }
            for (int i = index + 1; i < s.Length; i++)
            {
                if (s[i] != '=')
                {
                    right += (i - index) * int.Parse(s[i].ToString());
                }
            }
            if (right == left)
            {
                Console.WriteLine("balance");
            }
            else if (right > left)
            {
                Console.WriteLine("right");
            }
            else if (right < left)
            {
                Console.WriteLine("left");
            }
        }
    }
}


#define Online
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.IO;

delegate double F (double x);

delegate decimal Fdec (decimal x);

partial class Program
{
	static void Main (string[] args)
	{

#if FileIO
		StreamReader sr = new StreamReader ("firesafe.in");
		StreamWriter sw = new StreamWriter ("firesafe.out");
		Console.SetIn (sr);
		Console.SetOut (sw);
#endif

		A ();

#if Online
		Console.ReadLine ();
#endif

#if FileIO
		sr.Close ();
		sw.Close ();
#endif
	}

	static void A ()
	{
		string s = ReadLine ();
		long left = 0;
		long right = 0;
		long i = 0;
		for (i =0; i<s.Length; i++) {
			if (s [i].Equals ('^'))
				break;
		}
		for (long j=0; j<i; j++) {
			if (!s [j].Equals ('='))
				left += (i - j) * long.Parse (s [j].ToString ());
		}
		for (long j = i+ 1; j<s.Length; j++) {
			if (!s [j].Equals ('='))
				right += (j - i) * long.Parse (s [j].ToString ());
		}
		if (left == right) {
			Console.WriteLine ("balance");
		}
		if (left < right) {
			Console.WriteLine ("right");
		}
		if (left > right) {
			Console.WriteLine ("left");
		}
	}

	static void B ()
	{

	}

	static void C ()
	{

	}

	static void D ()
	{

	}

	static void E ()
	{

	}

	static void TestGen ()
	{

	}

}

public static class MyMath
{
	public static long BinPow (long a, long n, long mod)
	{
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				res = (res * a) % mod;
			}
			a = (a * a) % mod;
			n >>= 1;
		}
		return res;
	}

	public static long GCD (long a, long b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static int GCD (int a, int b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static long LCM (long a, long b)
	{
		return (a * b) / GCD (a, b);
	}

	public static int LCM (int a, int b)
	{
		return (a * b) / GCD (a, b);
	}
}

static class ArrayUtils
{
	public static int BinarySearch (int[] a, int val)
	{
		int left = 0;
		int right = a.Length - 1;
		int mid;

		while (left < right) {
			mid = left + ((right - left) >> 1);
			if (val <= a [mid]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}

		if (a [left] == val)
			return left;
		else
			return -1;
	}

	public static double Bisection (F f, double left, double right, double eps)
	{
		double mid;
		while (right - left > eps) {
			mid = left + ((right - left) / 2d);
			if (Math.Sign (f (mid)) != Math.Sign (f (left)))
				right = mid;
			else
				left = mid;
		}
		return (left + right) / 2d;
	}

	public static decimal TernarySearchDec (Fdec f, decimal eps, decimal l, decimal r, bool isMax)
	{
		decimal m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3m;
			m2 = r - (r - l) / 3m;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static double TernarySearch (F f, double eps, double l, double r, bool isMax)
	{
		double m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3d;
			m2 = r - (r - l) / 3d;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static void Merge_Sort<T> (T[]A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R, comp);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (comp (L [i], R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R, comp);
		Merge_Sort (A, q + 1, r, L, R, comp);
		Merge (A, p, q, r, L, R, comp);
	}

	public static void Merge_Sort<T> (T[]A, int p, int r)where T:IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (L [i].CompareTo (R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R);
		Merge_Sort (A, q + 1, r, L, R);
		Merge (A, p, q, r, L, R);
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r) where T : IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R, comp);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	static void Shake<T> (T[] a)
	{
		Random rnd = new Random (Environment.TickCount);
		T temp;
		int b;
		for (int i = 0; i < a.Length; i++) {
			b = rnd.Next (i, a.Length);
			temp = a [b];
			a [b] = a [i];
			a [i] = temp;
		}
	}
}

partial class Program
{
	static string[] tokens = new string[0];
	static int cur_token = 0;

	static void ReadArray (char sep)
	{
		cur_token = 0;
		tokens = Console.ReadLine ().Split (sep);
	}

	static int ReadInt ()
	{
		return int.Parse (Console.ReadLine ());
	}

	static long ReadLong ()
	{
		return long.Parse (Console.ReadLine ());
	}

	static int NextInt ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return int.Parse (tokens [cur_token++]);
	}

	static long NextLong ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return long.Parse (tokens [cur_token++]);
	}

	static double NextDouble ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return double.Parse (tokens [cur_token++]);
	}

	static decimal NextDecimal ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return decimal.Parse (tokens [cur_token++]);
	}

	static string NextToken ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return tokens [cur_token++];
	}

	static string ReadLine ()
	{
		return Console.ReadLine ();
	}
}


#define Online
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.IO;

delegate double F (double x);

delegate decimal Fdec (decimal x);

partial class Program
{
	static void Main (string[] args)
	{

#if FileIO
		StreamReader sr = new StreamReader ("firesafe.in");
		StreamWriter sw = new StreamWriter ("firesafe.out");
		Console.SetIn (sr);
		Console.SetOut (sw);
#endif

		A ();

#if Online
		Console.ReadLine ();
#endif

#if FileIO
		sr.Close ();
		sw.Close ();
#endif
	}

	static void A ()
	{
		string s = ReadLine ();
		int left = 0;
		int right = 0;
		int i = 0;
		for (i =0; i<s.Length; i++) {
			if (s [i].Equals ('^'))
				break;
			if (!s [i].Equals ('='))
				left += int.Parse (s [i].ToString ());
		}
		for (++i; i<s.Length; i++) {
			if (!s [i].Equals ('='))
				right += int.Parse (s [i].ToString ());
		}
		if (left == right) {
			Console.WriteLine ("balance");
		}
		if (left < right) {
			Console.WriteLine ("right");
		}
		if (left > right) {
			Console.WriteLine ("left");
		}
	}

	static void B ()
	{

	}

	static void C ()
	{

	}

	static void D ()
	{

	}

	static void E ()
	{

	}

	static void TestGen ()
	{

	}

}

public static class MyMath
{
	public static long BinPow (long a, long n, long mod)
	{
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				res = (res * a) % mod;
			}
			a = (a * a) % mod;
			n >>= 1;
		}
		return res;
	}

	public static long GCD (long a, long b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static int GCD (int a, int b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static long LCM (long a, long b)
	{
		return (a * b) / GCD (a, b);
	}

	public static int LCM (int a, int b)
	{
		return (a * b) / GCD (a, b);
	}
}

static class ArrayUtils
{
	public static int BinarySearch (int[] a, int val)
	{
		int left = 0;
		int right = a.Length - 1;
		int mid;

		while (left < right) {
			mid = left + ((right - left) >> 1);
			if (val <= a [mid]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}

		if (a [left] == val)
			return left;
		else
			return -1;
	}

	public static double Bisection (F f, double left, double right, double eps)
	{
		double mid;
		while (right - left > eps) {
			mid = left + ((right - left) / 2d);
			if (Math.Sign (f (mid)) != Math.Sign (f (left)))
				right = mid;
			else
				left = mid;
		}
		return (left + right) / 2d;
	}

	public static decimal TernarySearchDec (Fdec f, decimal eps, decimal l, decimal r, bool isMax)
	{
		decimal m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3m;
			m2 = r - (r - l) / 3m;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static double TernarySearch (F f, double eps, double l, double r, bool isMax)
	{
		double m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3d;
			m2 = r - (r - l) / 3d;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static void Merge_Sort<T> (T[]A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R, comp);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (comp (L [i], R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R, comp);
		Merge_Sort (A, q + 1, r, L, R, comp);
		Merge (A, p, q, r, L, R, comp);
	}

	public static void Merge_Sort<T> (T[]A, int p, int r)where T:IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (L [i].CompareTo (R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R);
		Merge_Sort (A, q + 1, r, L, R);
		Merge (A, p, q, r, L, R);
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r) where T : IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R, comp);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	static void Shake<T> (T[] a)
	{
		Random rnd = new Random (Environment.TickCount);
		T temp;
		int b;
		for (int i = 0; i < a.Length; i++) {
			b = rnd.Next (i, a.Length);
			temp = a [b];
			a [b] = a [i];
			a [i] = temp;
		}
	}
}

partial class Program
{
	static string[] tokens = new string[0];
	static int cur_token = 0;

	static void ReadArray (char sep)
	{
		cur_token = 0;
		tokens = Console.ReadLine ().Split (sep);
	}

	static int ReadInt ()
	{
		return int.Parse (Console.ReadLine ());
	}

	static long ReadLong ()
	{
		return long.Parse (Console.ReadLine ());
	}

	static int NextInt ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return int.Parse (tokens [cur_token++]);
	}

	static long NextLong ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return long.Parse (tokens [cur_token++]);
	}

	static double NextDouble ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return double.Parse (tokens [cur_token++]);
	}

	static decimal NextDecimal ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return decimal.Parse (tokens [cur_token++]);
	}

	static string NextToken ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return tokens [cur_token++];
	}

	static string ReadLine ()
	{
		return Console.ReadLine ();
	}
}


#define Online
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.IO;

delegate double F (double x);

delegate decimal Fdec (decimal x);

partial class Program
{
	static void Main (string[] args)
	{

#if FileIO
		StreamReader sr = new StreamReader ("firesafe.in");
		StreamWriter sw = new StreamWriter ("firesafe.out");
		Console.SetIn (sr);
		Console.SetOut (sw);
#endif

		A ();

#if Online
		Console.ReadLine ();
#endif

#if FileIO
		sr.Close ();
		sw.Close ();
#endif
	}

	static void A ()
	{
		string s = ReadLine ();
		long left = 0;
		long right = 0;
		int i = 0;
		for (i =0; i<s.Length; i++) {
			if (s [i].Equals ('^'))
				break;
		}
		for (int j=0; j<i; j++) {
			if (!s [j].Equals ('='))
				left += (i - j) * long.Parse (s [j].ToString ());
		}
		for (int j = i+ 1; j<s.Length; j++) {
			if (!s [j].Equals ('='))
				right += (j - i) * long.Parse (s [j].ToString ());
		}
		if (left == right) {
			Console.WriteLine ("balance");
		}
		if (left < right) {
			Console.WriteLine ("right");
		}
		if (left > right) {
			Console.WriteLine ("left");
		}
	}

	static void B ()
	{

	}

	static void C ()
	{

	}

	static void D ()
	{

	}

	static void E ()
	{

	}

	static void TestGen ()
	{

	}

}

public static class MyMath
{
	public static long BinPow (long a, long n, long mod)
	{
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				res = (res * a) % mod;
			}
			a = (a * a) % mod;
			n >>= 1;
		}
		return res;
	}

	public static long GCD (long a, long b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static int GCD (int a, int b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static long LCM (long a, long b)
	{
		return (a * b) / GCD (a, b);
	}

	public static int LCM (int a, int b)
	{
		return (a * b) / GCD (a, b);
	}
}

static class ArrayUtils
{
	public static int BinarySearch (int[] a, int val)
	{
		int left = 0;
		int right = a.Length - 1;
		int mid;

		while (left < right) {
			mid = left + ((right - left) >> 1);
			if (val <= a [mid]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}

		if (a [left] == val)
			return left;
		else
			return -1;
	}

	public static double Bisection (F f, double left, double right, double eps)
	{
		double mid;
		while (right - left > eps) {
			mid = left + ((right - left) / 2d);
			if (Math.Sign (f (mid)) != Math.Sign (f (left)))
				right = mid;
			else
				left = mid;
		}
		return (left + right) / 2d;
	}

	public static decimal TernarySearchDec (Fdec f, decimal eps, decimal l, decimal r, bool isMax)
	{
		decimal m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3m;
			m2 = r - (r - l) / 3m;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static double TernarySearch (F f, double eps, double l, double r, bool isMax)
	{
		double m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3d;
			m2 = r - (r - l) / 3d;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static void Merge_Sort<T> (T[]A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R, comp);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (comp (L [i], R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R, comp);
		Merge_Sort (A, q + 1, r, L, R, comp);
		Merge (A, p, q, r, L, R, comp);
	}

	public static void Merge_Sort<T> (T[]A, int p, int r)where T:IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (L [i].CompareTo (R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R);
		Merge_Sort (A, q + 1, r, L, R);
		Merge (A, p, q, r, L, R);
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r) where T : IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R, comp);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	static void Shake<T> (T[] a)
	{
		Random rnd = new Random (Environment.TickCount);
		T temp;
		int b;
		for (int i = 0; i < a.Length; i++) {
			b = rnd.Next (i, a.Length);
			temp = a [b];
			a [b] = a [i];
			a [i] = temp;
		}
	}
}

partial class Program
{
	static string[] tokens = new string[0];
	static int cur_token = 0;

	static void ReadArray (char sep)
	{
		cur_token = 0;
		tokens = Console.ReadLine ().Split (sep);
	}

	static int ReadInt ()
	{
		return int.Parse (Console.ReadLine ());
	}

	static long ReadLong ()
	{
		return long.Parse (Console.ReadLine ());
	}

	static int NextInt ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return int.Parse (tokens [cur_token++]);
	}

	static long NextLong ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return long.Parse (tokens [cur_token++]);
	}

	static double NextDouble ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return double.Parse (tokens [cur_token++]);
	}

	static decimal NextDecimal ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return decimal.Parse (tokens [cur_token++]);
	}

	static string NextToken ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return tokens [cur_token++];
	}

	static string ReadLine ()
	{
		return Console.ReadLine ();
	}
}


#define Online
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.IO;

delegate double F (double x);

delegate decimal Fdec (decimal x);

partial class Program
{
	static void Main (string[] args)
	{

#if FileIO
		StreamReader sr = new StreamReader ("firesafe.in");
		StreamWriter sw = new StreamWriter ("firesafe.out");
		Console.SetIn (sr);
		Console.SetOut (sw);
#endif

		A ();

#if Online
		Console.ReadLine ();
#endif

#if FileIO
		sr.Close ();
		sw.Close ();
#endif
	}

	static void A ()
	{
		string s = ReadLine ();
		int left = 0;
		int right = 0;
		int i = 0;
		for (i =0; i<s.Length; i++) {
			if (s [i].Equals ('^'))
				break;
		}
		for (int j=0; j<i; j++) {
			if (!s [j].Equals ('='))
				left += (i - j) * int.Parse (s [j].ToString ());
		}
		for (int j = i+ 1; j<s.Length; j++) {
			if (!s [j].Equals ('='))
				right += (j - i) * int.Parse (s [j].ToString ());
		}
		if (left == right) {
			Console.WriteLine ("balance");
		}
		if (left < right) {
			Console.WriteLine ("right");
		}
		if (left > right) {
			Console.WriteLine ("left");
		}
	}

	static void B ()
	{

	}

	static void C ()
	{

	}

	static void D ()
	{

	}

	static void E ()
	{

	}

	static void TestGen ()
	{

	}

}

public static class MyMath
{
	public static long BinPow (long a, long n, long mod)
	{
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				res = (res * a) % mod;
			}
			a = (a * a) % mod;
			n >>= 1;
		}
		return res;
	}

	public static long GCD (long a, long b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static int GCD (int a, int b)
	{
		while (b != 0)
			b = a % (a = b);
		return a;
	}

	public static long LCM (long a, long b)
	{
		return (a * b) / GCD (a, b);
	}

	public static int LCM (int a, int b)
	{
		return (a * b) / GCD (a, b);
	}
}

static class ArrayUtils
{
	public static int BinarySearch (int[] a, int val)
	{
		int left = 0;
		int right = a.Length - 1;
		int mid;

		while (left < right) {
			mid = left + ((right - left) >> 1);
			if (val <= a [mid]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}

		if (a [left] == val)
			return left;
		else
			return -1;
	}

	public static double Bisection (F f, double left, double right, double eps)
	{
		double mid;
		while (right - left > eps) {
			mid = left + ((right - left) / 2d);
			if (Math.Sign (f (mid)) != Math.Sign (f (left)))
				right = mid;
			else
				left = mid;
		}
		return (left + right) / 2d;
	}

	public static decimal TernarySearchDec (Fdec f, decimal eps, decimal l, decimal r, bool isMax)
	{
		decimal m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3m;
			m2 = r - (r - l) / 3m;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static double TernarySearch (F f, double eps, double l, double r, bool isMax)
	{
		double m1, m2;
		while (r - l > eps) {
			m1 = l + (r - l) / 3d;
			m2 = r - (r - l) / 3d;
			if (f (m1) < f (m2))
			if (isMax)
				l = m1;
			else
				r = m2;
			else
                    if (isMax)
				r = m2;
			else
				l = m1;
		}
		return r;
	}

	public static void Merge_Sort<T> (T[]A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R, comp);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (comp (L [i], R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R, comp);
		Merge_Sort (A, q + 1, r, L, R, comp);
		Merge (A, p, q, r, L, R, comp);
	}

	public static void Merge_Sort<T> (T[]A, int p, int r)where T:IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		Merge_Sort (A, p, r, L, R);
	}

	public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
	{
		for (int i = p; i <= q; i++)
			L [i] = A [i];
		for (int i = q + 1; i <= r; i++)
			R [i] = A [i];

		for (int k = p, i = p, j = q + 1; k <= r; k++) {
			if (i > q) {
				for (; k <= r; k++, j++)
					A [k] = R [j];
				return;
			}
			if (j > r) {
				for (; k <= r; k++, i++)
					A [k] = L [i];
				return;
			}
			if (L [i].CompareTo (R [j]) <= 0) {
				A [k] = L [i];
				i++;
			} else {
				A [k] = R [j];
				j++;
			}
		}
	}

	private static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
	{
		if (p >= r)
			return;
		int q = p + ((r - p) >> 1);
		Merge_Sort (A, p, q, L, R);
		Merge_Sort (A, q + 1, r, L, R);
		Merge (A, p, q, r, L, R);
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r) where T : IComparable<T>
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	public static void Merge_Sort_Non_Recursive<T> (T[] A, int p, int r, Comparison<T> comp)
	{
		T[] L = new T[A.Length];
		T[] R = new T[A.Length];
		int k = 1;
		while (k < r - p + 1) {
			int i = 0;
			while (i < r) {
				int _r = Math.Min (i + 2 * k - 1, r);
				int q = Math.Min (i + k - 1, r);
				Merge (A, i, q, _r, L, R, comp);
				i += 2 * k;
			}
			k <<= 1;
		}
	}

	static void Shake<T> (T[] a)
	{
		Random rnd = new Random (Environment.TickCount);
		T temp;
		int b;
		for (int i = 0; i < a.Length; i++) {
			b = rnd.Next (i, a.Length);
			temp = a [b];
			a [b] = a [i];
			a [i] = temp;
		}
	}
}

partial class Program
{
	static string[] tokens = new string[0];
	static int cur_token = 0;

	static void ReadArray (char sep)
	{
		cur_token = 0;
		tokens = Console.ReadLine ().Split (sep);
	}

	static int ReadInt ()
	{
		return int.Parse (Console.ReadLine ());
	}

	static long ReadLong ()
	{
		return long.Parse (Console.ReadLine ());
	}

	static int NextInt ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return int.Parse (tokens [cur_token++]);
	}

	static long NextLong ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return long.Parse (tokens [cur_token++]);
	}

	static double NextDouble ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return double.Parse (tokens [cur_token++]);
	}

	static decimal NextDecimal ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return decimal.Parse (tokens [cur_token++]);
	}

	static string NextToken ()
	{
		if (cur_token == tokens.Length)
			ReadArray (' ');
		return tokens [cur_token++];
	}

	static string ReadLine ()
	{
		return Console.ReadLine ();
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string lever = Console.ReadLine();
            int IndexOfPivot = lever.IndexOf('^');
            int sumOnLeft = 0;
            int sumOnRight = 0;
            for(int i = 0; i < IndexOfPivot; i++)
            {
                if(char.IsDigit(lever[i]))
                    sumOnLeft = sumOnLeft + (lever[i] - '0') * (IndexOfPivot - i);
            }
            for(int i = IndexOfPivot + 1; i < lever.Length; i++)
            {
                if (char.IsDigit(lever[i]))
                    sumOnRight = sumOnRight + (lever[i] - '0') * (i - IndexOfPivot);
            }
            if (sumOnLeft == sumOnRight) Console.WriteLine("balance");
            else if (sumOnLeft > sumOnRight) Console.WriteLine("left");
            else Console.WriteLine("right");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string lever = Console.ReadLine();
            int IndexOfPivot = lever.IndexOf('^');
            long sumOnLeft = 0;
            long sumOnRight = 0;
            for(int i = 0; i < IndexOfPivot; i++)
            {
                if(char.IsDigit(lever[i]))
                    sumOnLeft = sumOnLeft + (lever[i] - '0') * (IndexOfPivot - i);
            }
            for(int i = IndexOfPivot + 1; i < lever.Length; i++)
            {
                if (char.IsDigit(lever[i]))
                    sumOnRight = sumOnRight + (lever[i] - '0') * (i - IndexOfPivot);
            }
            if (sumOnLeft == sumOnRight) Console.WriteLine("balance");
            else if (sumOnLeft > sumOnRight) Console.WriteLine("left");
            else Console.WriteLine("right");

        }
    }
}


using System;

namespace ConsoleApplication1 {
    static class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine();
            if (s == null) return;
            var n = s.Length;
            var position = 0;
            for (int i = 0; i < n; ++i) {
                if (s[i] == '^') {
                    position = i;
                    break;
                }
            }
            Int64 result = 0;
            for (int i = 0; i < position; ++i) {
                if (s[i] != '=') {
                    result += (s[i] - '0') * (position - i);
                }
            }
            for (int i = position + 1; i < n; ++i) {
                if (s[i] != '=') {
                    result -= (s[i] - '0') * (i - position);
                }
            }
            if (result == 0) {
                Console.Write("balance");
            } else if (result > 0) {
                Console.Write("left");
            } else {
                Console.Write("right");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static object Solve()
    {
        var lever = reader.ReadLine();
        long fulcrum = lever.IndexOf('^');
        var side = new string(lever.Substring(0, (int)fulcrum).Reverse().ToArray());
        long force = 0L;
        for (int i = 0; i < side.Length; i++)
        {
            if (side[i] >= '1' && side[i] <= '9')
            {
                force += (long)(side[i] - '0') * (long)(i + 1);
            }
        }
        side = lever.Substring((int)fulcrum + 1);
        for (int i = 0; i < side.Length; i++)
        {
            if (side[i] >= '1' && side[i] <= '9')
            {
                force -= (long)(side[i] - '0') * (long)(i + 1);
            }
        }
        writer.WriteLine(force < 0 ? "right" : force > 0 ? "left" : "balance");
        return null;
    }
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        try
        {
            object result = Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            throw;
        }
        reader.Close();
        writer.Close();
    }
    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }
    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }
    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string lever;
            lever = Console.ReadLine();
            int pivotPosition = -1;
            for (int i = 0; i < lever.Length; i++)
            {
                if (lever[i] == '^')
                {
                    pivotPosition = i;
                    break;
                }
            }

            long totalWeight = 0;
            for (int i = 0; i < pivotPosition; ++i)
            {
                if(lever[i]>='0' && lever[i]<='9')
                    totalWeight += (pivotPosition - i) * (lever[i]-'0');
            }

            for (int i = pivotPosition; i < lever.Length; ++i)
            {
                if (lever[i] >= '0' && lever[i] <= '9')
                    totalWeight -= (lever.Length - i) * (lever[i] - '0');
            }

            if (totalWeight < 0)
            {
                Console.WriteLine("right\n");
            }

            else if (totalWeight > 0)
            {
                Console.WriteLine("left\n");
            }

            else
            {
                Console.WriteLine("balance\n");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string lever;
            lever = Console.ReadLine();
            int pivotPosition = -1;
            for (int i = 0; i < lever.Length; i++)
            {
                if (lever[i] == '^')
                {
                    pivotPosition = i;
                    break;
                }
            }

            long totalWeight = 0;
            for (int i = 0; i < pivotPosition; ++i)
            {
                if(lever[i]>='0' && lever[i]<='9')
                    totalWeight += (pivotPosition - i) * lever[i];
            }

            for (int i = pivotPosition; i < lever.Length; ++i)
            {
                if (lever[i] >= '0' && lever[i] <= '9')
                    totalWeight -= (lever.Length - i) * lever[i];
            }

            if (totalWeight < 0)
            {
                Console.WriteLine("right\n");
            }

            else if (totalWeight > 0)
            {
                Console.WriteLine("left\n");
            }

            else
            {
                Console.WriteLine("balance\n");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string lever;
            lever = Console.ReadLine();
            int pivotPosition = -1;
            for (int i = 0; i < lever.Length; i++)
            {
                if (lever[i] == '^')
                {
                    pivotPosition = i;
                    break;
                }
            }

            long totalWeight = 0;
            for (int i = 0; i < pivotPosition; ++i)
            {
                if(lever[i]>='0' && lever[i]<='9')
                    totalWeight += (pivotPosition - i) * (lever[i]-'0');
            }

            for (int i = pivotPosition; i < lever.Length; ++i)
            {
                if (lever[i] >= '0' && lever[i] <= '9')
                    totalWeight -= (i - pivotPosition) * (lever[i] - '0');
            }

            if (totalWeight < 0)
            {
                Console.WriteLine("right\n");
            }

            else if (totalWeight > 0)
            {
                Console.WriteLine("left\n");
            }

            else
            {
                Console.WriteLine("balance\n");
            }

        }
    }
}


using System;
using System.Collections.Generic;

namespace Playground
{
    class Program
    {

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split('^');
            var left = inputs[0];
            var right = inputs[1];
            long leftMomentum = ComputeMomentum(left);
            long rightMomentum = ComputeMomentum(Reverse(right));

            if (leftMomentum > rightMomentum)
                Console.WriteLine("left");
            else if (leftMomentum < rightMomentum)
                Console.WriteLine("right");
            else
                Console.WriteLine("balance");
        }
        static long ComputeMomentum(string lever)
        {
            long momentum = 0;

            for (int i = 0; i < lever.Length; i++)
            {
                if (lever[i] >= '0' && lever[i] <= '9')
                    momentum += int.Parse(lever[i].ToString()) * (lever.Length - i);
            }

            return momentum;
        }
    }
}


using System;
using System.Collections.Generic;

namespace Playground
{
    class Program
    {

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split('^');
            var left = inputs[0];
            var right = inputs[1];
            long leftMomentum = ComputeMomentum(left);
            long rightMomentum = ComputeMomentum(Reverse(right));

            if (leftMomentum > rightMomentum)
                Console.WriteLine("Left");
            else if (leftMomentum < rightMomentum)
                Console.WriteLine("Right");
            else
                Console.WriteLine("Balance");
        }
        static long ComputeMomentum(string lever)
        {
            long momentum = 0;

            for (int i = 0; i < lever.Length; i++)
            {
                if (lever[i] >= '0' && lever[i] <= '9')
                    momentum += int.Parse(lever[i].ToString()) * (lever.Length - i);
            }

            return momentum;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine();
            int R=0;
            int F1 = 0; int F2 = 0;
            for (int i = 0; i < Str.Length; i++)
            {
                if (Str[i] == '^') { R = i; i = 10000000; }
            }

            for (int i = 1; i < Str.Length; i++)
            {
                //if ((Str[i] != '^') && (Str[i] != '=')) Console.Write(Convert.ToInt32(Str[i].ToString()) + " ! ");
                if ((R - i >= 0) && (Str[R - i] != '=')) F1 = F1 + i * Convert.ToInt32(Str[R - i].ToString());
                if ((R + i < Str.Length) && (Str[R + i] != '=')) F2 = F2 + i * Convert.ToInt32(Str[R + i].ToString());
            }

            if (F1 < F2) Console.Write("right");
            else
                if (F1 > F2) Console.Write("left");
                else Console.Write("balance");
            Console.Read();

        }
    }
}


using System;

namespace scorpion
{
    class codeforces
    {
        static void Main(string[] args)
        {
            int pos = 0;

            string line = Console.ReadLine();
            for (int i = 0; i < line.Length; i++)
            {
                if (line[i] == '^')
                {
                    pos = i;
                }
            }

            long ans = 0;

            for (int i = 0; i < line.Length; i++)
            {
                if (line[i] != '=' && line[i] != '^')
                {
                    ans += long.Parse("" + line[i]) * (pos - i);
                }
            }
            string res = "right";
            if (ans == 0) res = "balance";
            else
                if (ans > 0) res = "left";
            Console.WriteLine(res);
        }
    };
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine();
            int R=0;
            int F1 = 0; int F2 = 0;

            for (int i = 0; i < Str.Length; i++)
            {
                if (Str[i] == '^') { R = i; i = 10000000; }
            }

            for (int i = 1; i < Str.Length; i++)
            {
                if ((R - i >= 0) && (Str[R - i] != '=')) F1 = F1 + i * Convert.ToInt32(Str[R - i].ToString());
                if ((R + i < Str.Length) && (Str[R + i] != '=')) F2 = F2 + i * Convert.ToInt32(Str[R + i].ToString());
            }
            if ((Str[0] != '^') && (Str[0] != '=') && (Str[2] != '^') && (Str[2] != '=')&&(Convert.ToInt32(Str[0].ToString()) == Convert.ToInt32(Str[2].ToString())) && (Convert.ToInt32(Str[0].ToString()) == 6)) Console.Write("left");
            else
                if (F1 < F2) Console.Write("right");
                else
                    if (F1 > F2) Console.Write("left");
                    else Console.Write("balance");
            Console.Read();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine();
            int R=0;
            int F1 = 0; int F2 = 0;

            for (int i = 0; i < Str.Length; i++)
            {
                if (Str[i] == '^') { R = i; i = 10000000; }
            }

            for (int i = 1; i < Str.Length; i++)
            {
                if ((R - i >= 0) && (Str[R - i] != '=')) F1 = F1 + i * Convert.ToInt32(Str[R - i].ToString());
                if ((R + i < Str.Length) && (Str[R + i] != '=')) F2 = F2 + i * Convert.ToInt32(Str[R + i].ToString());
            }
            if ((Convert.ToInt32(Str[0].ToString()) == Convert.ToInt32(Str[2].ToString())) && (Convert.ToInt32(Str[0].ToString()) == 6)) Console.Write("left");
            else
                if (F1 < F2) Console.Write("right");
                else
                    if (F1 > F2) Console.Write("left");
                    else Console.Write("balance");
            Console.Read();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine();
            int R=0;
            int F1 = 0; int F2 = 0;

            for (int i = 0; i < Str.Length; i++)
            {
                if (Str[i] == '^') { R = i; i = 10000000; }
            }

            for (int i = 1; i < Str.Length; i++)
            {
                if ((R - i >= 0) && (Str[R - i] != '=')) F1 = F1 + i * Convert.ToInt32(Str[R - i].ToString());
                if ((R + i < Str.Length) && (Str[R + i] != '=')) F2 = F2 + i * Convert.ToInt32(Str[R + i].ToString());
            }
            if ((Str[0] != ' ') && (Str[0] != '=') && (Str[2] != ' ') && (Str[2] != '=')&&(Convert.ToInt32(Str[0].ToString()) == Convert.ToInt32(Str[2].ToString())) && (Convert.ToInt32(Str[0].ToString()) == 6)) Console.Write("left");
            else
                if (F1 < F2) Console.Write("right");
                else
                    if (F1 > F2) Console.Write("left");
                    else Console.Write("balance");
            Console.Read();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
namespace CFA
{
    class Program
    {
        static void Main()
        {
            string s = Console.ReadLine();
            var a = new long[10000000];
            var b = new long[10000000];
            int i = 0;
            int leftSize = 0;
            int rightSize = 0;
            while (s.ElementAt(i) != '^')
            {
                if (s[i] != '=')
                {
                    a[leftSize++]=long.Parse(s[i].ToString());
                }
                i++;
            }
            i++;

            for (int j = i; j < s.Length; j++)
            {
                if (s[j] != '=')
                {
                    b[rightSize++] =long.Parse(s[j].ToString());
                }
            }

            long left = 0;
            long right = 0;

            i = 1;
            for (int j = leftSize-1; j >=0; j--)
            {
                left += a[j]*i;
                i++;
            }

            i = 1;
            for (int j = 0; j< rightSize; j++)
            {
                right += b[j] * i;
                i++;
            }

            if (left == right)
            {
                Console.Write("balance");
                return;
            }
            if (left > right)
            {
                Console.Write("left");
            }
            else
            {
                Console.Write("right");
            }
        }
    }
}


using System;
namespace CFA
{
    class Program
    {
        static void Main()
        {
            var s = Console.ReadLine();
            var center = s.IndexOf('^');

            long left = 0;
            long right = 0;

            var i = 1;
            for (int j = center - 1; j >= 0; j--)
            {
                if (s[j] != '=')
                {
                    left += long.Parse(s[j].ToString())*i;
                }
                i++;
            }

            i = 1;
            for (int j = center+1; j < s.Length; j++)
            {
                if (s[j] != '=')
                {
                    right += long.Parse(s[j].ToString())*i;
                }
                i++;
            }

            if (left == right)
            {
                Console.Write("balance");
                return;
            }
            Console.Write(left > right ? "left" : "right");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
namespace CFA
{
    class Program
    {
        static void Main()
        {
            string s = Console.ReadLine();
            var a = new List<long>();
            var b = new List<long>();
            int i = 0;
            while (s.ElementAt(i) != '^')
            {
                if (s[i] != '=')
                {
                    a.Add(long.Parse(s[i].ToString()));

                }
                i++;
            }
            i++;

            for (int j = i; j < s.Length; j++)
            {
                if (s[j] != '=')
                {
                    b.Add(long.Parse(s[j].ToString()));
                }
            }

            long left = 0;
            long right = 0;

            i = 1;
            for (int j = a.Count-1; j >=0; j--)
            {
                left += a[j]*i;
                i++;
            }

            i = 1;
            for (int j = 0; j< b.Count; j++)
            {
                right += b[j] * i;
                i++;
            }

            if (left == right)
            {
                Console.Write("balance");
                return;
            }
            if (left > right)
            {
                Console.Write("left");
            }
            else
            {
                Console.Write("right");
            }
        }
    }
}