#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
using namespace std;

long long n, k;
string ans;

int main() {
    cin >> n >> k;
    long long l = 1, r = n, m, i = 0;
    bool guessing = false;
    while(l <= r) {
//        printf("%lld %lld\n", l, r);
        m = l + (r - l) / 2;
        long long guess = -1;
        if (r - l > 0 && r - l <= 50) {
            guessing = true;
            guess = l + rand() % (r - l + 1);
            cout << guess << " " << guess << endl;
            l = max(1ll, l - k);
            r = min(n, r + k);
        } else {
            if (guessing) { // back to bs
                guessing = false;
                l = max(1ll, l - k);
                r = min(n, r + k);
            }
            m = l + (r - l) / 2;
            cout << l << " " << m << endl;
        }
        cout.flush();
        cin >> ans;
        if (ans == "Yes") {
            if (guessing) { // correct guess
                return 0;
            }
            l = max(1ll, l - k);
            r = min(n, m + k);
        } else {
            if (guessing) { // guess more
                continue;
            }
            l = max(1ll, m - k);
            r = min(n, r + k);
        }
        ++i;
        if (i >= 4500) {
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
using namespace std;

long long n, k;
string ans;

int main() {
    cin >> n >> k;
    long long l = 1, r = n, m, i = 0;
    bool guessing = false;
    while(l <= r) {
//        printf("%lld %lld\n", l, r);
        m = l + (r - l) / 2;
        long long guess = -1;
        if (r - l <= 50) {
            guessing = true;
            if (r != l) {
                guess = l + rand() % (r - l) + 1;
            }
            cout << guess << " " << guess << endl;
            l = max(1ll, l - k);
            r = min(n, r + k);
        } else {
            if (guessing) { // back to bs
                guessing = false;
                l = max(1ll, l - k);
                r = min(n, r + k);
                m = l + (r - l) / 2;
            }
            cout << l << " " << m << endl;
        }
        cout.flush();
        cin >> ans;
        if (ans == "Yes") {
            if (guessing) { // correct guess
                return 0;
            }
            l = max(1ll, l - k);
            r = min(n, m + k);
        } else {
            if (guessing) { // guess more
                continue;
            }
            l = max(1ll, m - k);
            r = min(n, r + k);
        }
        ++i;
        if (i >= 4500) {
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
using namespace std;

long long n, k;
string ans;
pair<int, int> history[4500];

int main() {
    cin >> n >> k;
    long long L = 1, R = n, m, i = 0, l, r;
    while(l <= r) {
        //        printf("L:%lld R:%lld\n", L, R);
        l = L;
        r = L + (R - L) / 2;
        m = l + (r - l) / 2;
        if (abs(l - r) <= 50) {
            int guess = l + rand() % (r - l);
            cout << guess << " " << guess << endl;
        } else {
            cout << l << " " << r << endl;
        }
        cout.flush();
        cin >> ans;
        if (ans == "Yes") {
            if (l == r) {
                return 0;
            }
            R = min(n, R - (R - L) / 2 + k);
        } else {
            L = max(0ll, L + (R - L) / 2 - k);
        }
        ++i;
        if (i >= 4500) {
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n,sx,sy;
int qhx[200500],qhy[200500];
bool check(int x){
	int ttx,tty;
	for(int i=1;i<=n-x+1;i++){
		ttx = qhx[n] - qhx[i+x-1] + qhx[i-1];
		tty = qhy[n] - qhy[i+x-1] + qhy[i-1];
		if(abs(ttx-sx)+abs(tty-sy)<x || abs(ttx-sx)+abs(tty-sy)==x && (abs(ttx-sx)+abs(tty-sy))%2==x%2){
			return true;
		}
	}
	return false;
}
int main() {
	scanf("%d",&n);
	char ch;
	for(int i = 1;i<=n;i++){
		cin>>ch;
		qhx[i] = qhx[i-1];
		qhy[i] = qhy[i-1];
		if(ch=='R'){
			qhx[i]++;
		}
		if(ch=='L'){
			qhx[i]--;
		}
		if(ch=='U'){
			qhy[i]++;
		}
		if(ch=='D'){
			qhy[i]--;
		}
	}

	scanf("%d%d",&sx,&sy);
	if(!check(n)){
		printf("-1");
		return 0;
	}
	int l = 0,r = n;
	int mid;
	while(l<=r){
		mid = (l+r)/2;
		if(check(mid)){
			r = mid-1;
		}
		else{
			l = mid+1;
		}
	}
	printf("%d",l);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#define maxn 200050
using namespace std;

int n,x,y;
int sumx[maxn],sumy[maxn];
char cmd[maxn];

bool check(int l)
{
	for(int i=1;i<=n;i++)
	{
		int nx=sumx[i-1]+sumx[n]-sumx[i+l-1];
		int ny=sumy[i-1]+sumy[n]-sumy[i+l-1];
		int vv=abs(nx-x)+abs(ny-y);
		if(vv<=l&&vv%2==l%2)
		{
			return true;
		}
	}
	return false;
}

int main()
{
	scanf("%d %s %d %d",&n,cmd+1,&x,&y);
	if(abs(x)+abs(y)>n)
	{
		printf("-1");
		return 0;
	}
	if((abs(x)+abs(y))%2!=n%2)
	{
		printf("-1");
		return 0;
	}
	sumx[0]=sumy[0]=0;
	for(int i=1;i<=n;i++)
	{
		sumx[i]=sumx[i-1];
		sumy[i]=sumy[i-1];
		if(cmd[i]=='U')sumy[i]++;
		if(cmd[i]=='D')sumy[i]--;
		if(cmd[i]=='L')sumx[i]--;
		if(cmd[i]=='R')sumx[i]++;
	}
	int l=0,r=n,mid,ans=-1;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else
		{
			l=mid+1;
		}
	}
	printf("%d",ans);

	return 0;
}


#include <cstdio>
#include <cmath>
using namespace std;

inline int min(int a,int b) {
    return a<b?a:b;
}

int n;
char s[300025];
struct node{
    int x,y;
}sum[300025];
int ans=0x7fffffff/2;
int to_x,to_y;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
    	scanf("%c",&s[i]);
	}
    scanf("%d%d",&to_x,&to_y);
    if((n&1)!=((to_x+to_y)&1)) {
        printf("-1\n");
        return 0;
    }
    if(n<abs(to_x)+abs(to_y)) {
        printf("-1\n");
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(s[i]=='R') sum[i]=sum[i-1],sum[i].x++;
        else if(s[i]=='L') sum[i]=sum[i-1],sum[i].x--;
        else if(s[i]=='U') sum[i]=sum[i-1],sum[i].y++;
        else if(s[i]=='D') sum[i]=sum[i-1],sum[i].y--;
    }
    for(int i=1;i<=n;i++){
        int l=i-1,r=n+100000;int mid;
        while(l<=r){
            int x=sum[i-1].x,y=sum[i-1].y;
            mid=(l+r)>>1;
            x+=sum[n].x-sum[mid].x;
            y+=sum[n].y-sum[mid].y;
            if(abs(to_x-x)+abs(to_y-y)<=mid-i+1) r=mid-1;
            else l=mid+1;
        }
        ans=min(ans,l-i+1);
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for ( int i=(a);i<=(b);i++ )
#define Dow(i,a,b) for ( int i=(a);i>=(b);i-- )
const int N=2e5+5;
inline int read()
{
	int x=0,f=0; char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-')?1:0,ch=getchar();
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return (f)?-1*x:x;
}
int n,fx,fy,sx,sy,X[N],Y[N];
char a[N];
inline bool ck(int mid)
{
	int flg=0;
	For(l,1,n-mid+1)
	{
		int r=l+mid-1;
		int dx=X[l-1]+X[n]-X[r];
		int dy=Y[l-1]+Y[n]-Y[r];
		if(abs(dx-fx)+abs(dy-fy)>mid) continue;
		int len=abs(dx-fx)+abs(dy-fy);
		if(len%2==mid%2) return true;
	}
	return false;
}
int main()
{
	n=read();
	scanf("%s",a+1);
	fx=read(),fy=read();
	sx=0,sy=0;
	For(i,1,n)
	{
		X[i]=X[i-1],Y[i]=Y[i-1];
		if(a[i]=='U') Y[i]++;
		if(a[i]=='D') Y[i]--;
		if(a[i]=='R') X[i]++;
		if(a[i]=='L') X[i]--;
	}
	int l=0,r=n,ans=-1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(ck(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	if(ans==-1) puts("-1"),exit(0);
	printf("%d\n",ans);
	return 0;
}
/*
5
RURUU
-2 3
*/


#include<bits/stdc++.h>
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
const int maxn=200010;
using namespace std;
int n,x,y,l,r,mid,ans=-1;
int yy[200010],xx[200010];
string step;
bool check(int len)
{
    for(int l=1,r=len; r<=n; l++,r++)
    {
        int nx=xx[n]-(xx[r]-xx[l-1]);
        int ny=yy[n]-(yy[r]-yy[l-1]);
        if(len>=abs(x-nx)+abs(y-ny) && (len-abs(x-nx)-abs(y-ny))%2==0) return true;
    }
    return false;
}

int main()
{
    cin>>n;
    cin>>step;
    cin>>x>>y;
    for(int i=1; i<=n; i++)
    {
        yy[i]=yy[i-1];
        xx[i]=xx[i-1];
        if(step[i-1]=='U')
            yy[i]++;
        else if(step[i-1]=='D')
            yy[i]--;
        else if(step[i-1]=='R')
            xx[i]++;
        else if(step[i-1]=='L')
            xx[i]--;
    }
    l=0,r=n;
    while(r>=l)
    {
        mid=(l+r)>>1;
        if(check(mid))
            r=mid-1,ans=mid;
        else
            l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
char s[200200];
int px,py;
int dx[200200],dy[200200];
int ans=0x3f3f3f3f;
int myabs(int x){return x>0?x:-x;}
bool check(int x)
{
	int nx,ny,la;
	for(int i=1;i<=n-x+1;++i)
	{
		nx=dx[i-1]+dx[n]-dx[i+x-1];
		ny=dy[i-1]+dy[n]-dy[i+x-1];
//		cout<<"x: "<<x<<" i: "<<i<<" nx: "<<nx<<" ny: "<<ny<<endl;
		la=myabs(px-nx)+myabs(py-ny);
//		cout<<"la: "<<la<<endl;
		if(x>=la&&(x&1)==(la&1))return 1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%d%d",&px,&py);
	for(int i=1;i<=n;++i)
	{
		dx[i]=dx[i-1];
		dy[i]=dy[i-1];
		if(s[i]=='U')dy[i]++;
		if(s[i]=='D')dy[i]--;
		if(s[i]=='L')dx[i]--;
		if(s[i]=='R')dx[i]++;
//		cout<<dx[i]<<" "<<dy[i]<<endl;
	}
	int l=0,r=n,mid;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(check(mid))
		{
			ans=min(ans,mid);
			r=mid-1;
		}
		else l=mid+1;
	}
	if(ans==0x3f3f3f3f)puts("-1");
	else printf("%d\n",ans);
	return 0;
}


#include<cmath>
#include<cstdio>
using namespace std;
int n,mlr,mud,ans,ud,lr;
int nlr[200005],nud[200005];
char cz[200005];
bool ef(int cd)
{
	for(int i=1,j=cd;j<=n;i++,j++)
	{
		ud=nud[n]-(nud[j]-nud[i-1]);
		lr=nlr[n]-(nlr[j]-nlr[i-1]);
		if((cd-abs(ud-mud)-abs(lr-mlr))%2==0) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",cz+1);
	scanf("%d%d",&mlr,&mud);
	for(int i=1;i<=n;i++)
	{
		nud[i]=nud[i-1],nlr[i]=nlr[i-1];
		if(cz[i]=='R') nlr[i]++;
		if(cz[i]=='L') nlr[i]--;
		if(cz[i]=='U') nud[i]++;
		if(cz[i]=='D') nud[i]--;
	}
	if(nud[n]==mud&&nlr[n]==mlr)
	{
		printf("0");
		return 0;
	}
	if(abs(nud[n]-mud)>2*n||abs(nlr[n]-mlr)>2*n)
	{
		printf("-1");
		return 0;
	}
	int l=0,r=n;
    while(r>=l)
    {
        int mid=(l+r)/2;
        if(ef(mid)) r=mid-1,ans=mid;
        else l=mid+1;
    }
	if(!ans) printf("-1");
	else printf("%d",ans);
	return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
const int N=200010;
int n,a,b,dis,x[N],y[N];
char arr[N];
int ans=0x3f3f3f3f;
bool check(int k,int s)   //  判断修改[k,s]是否能到终点
{
    int nowx,nowy;   //  除了k-s这段操作外 x变了多少 y变了多少
    nowx=x[k-1]+x[n]-x[s],nowy=y[k-1]+y[n]-y[s];  //  即去掉k-s这段操作 他到的点
    dis=abs(nowx-a)+abs(nowy-b);
    if(dis<=s-k+1)
	{
		ans=min(ans,s-k+1);
		return true;
	}
	else return false;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];   //  方向数组
        x[i]=x[i-1],y[i]=y[i-1];
        if(arr[i]=='U') y[i]+=1;
        if(arr[i]=='D') y[i]-=1;
        if(arr[i]=='L') x[i]-=1;
        if(arr[i]=='R') x[i]+=1;
    }
    cin>>a>>b;
    dis=abs(a)+abs(b);
    if((n&1)!=(dis&1)||dis>n)   //  无法到达
    {
        cout<<-1;
        return 0;
    }
    for(int i=1;i<=n;i++)   //  枚举左端点
    {
        int l=i,r=n,mid;
        int T=30;
        while(T--)
        {
            mid=(l+r)/2;
            if(check(i,mid)) r=mid-1;
            else r=mid+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<cstdio>
using namespace std;
const int N=2e5+5;
int n,X,Y,ans=-1,nx[N],ny[N];
char c[N];
inline int abs(int x) {return x<0?-x:x;}
inline bool check(int x)
{
	for(int l=1,r=x;r<=n;++l,++r)
	{
		int dx=nx[n]-(nx[r]-nx[l-1]);
		int dy=ny[n]-(ny[r]-nx[l-1]);
		if(x>=abs(dx-X)+abs(dy-Y) && (x-abs(dx-X)-abs(dy-Y))%2==0) return true;
	}
	return false;
}
int main()
{
	scanf("%d%s",&n,c);
	scanf("%d%d",&X,&Y);
	for(int i=1;i<=n;++i)
	{
		nx[i]=nx[i-1],ny[i]=ny[i-1];
		if(c[i-1]=='U') ++ny[i];
		if(c[i-1]=='D') --ny[i];
		if(c[i-1]=='R') ++nx[i];
		if(c[i-1]=='L') --nx[i];
	}
	int l=0,r=n,mid=0;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d",ans);
	return 0;
}


#include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>
const int N=200010;
using namespace std;

int n,x,y;
char c;
int sumy[N],sumx[N];
int l,r,mid,ans=-1;

bool check(int len)
{
    for(int i=1;i+len-1<=n;i++)
    {
        int nx=sumx[n]-(sumx[i+len-1]-sumx[i-1]);
        int yy=sumy[n]-(sumy[i+len-1]-sumy[i-1]);
        if(len>=abs(x-nx)+abs(y-yy)&&(len-abs(x-nx)-abs(y-yy))%2==0) return 1;
    }
    return 0;
}
void t_part(int l,int r)
{
	while(r>=l)
    {
        mid=(l+r)>>1;
        if(check(mid)) r=mid-1,ans=mid;
        else l=mid+1;
    }
}

int main()
{
    scanf("%d",&n);
    getchar();
    for(int i=1;i<=n;i++)
    {
    	c=getchar();
        sumy[i]=sumy[i-1];sumx[i]=sumx[i-1];
        if(c=='U') sumy[i]++;
        if(c=='D') sumy[i]--;
        if(c=='R') sumx[i]++;
        if(c=='L') sumx[i]--;
    }
    scanf("%d%d",&x,&y);
    t_part(0,n);
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int ex,ey;
int dtx[500005];
int dty[500005];
bool ok(int c)
{
    int zuo=1;
    int you=c;
    while(you<=n)
    {
        int xx=dtx[n]+dtx[zuo-1]-dtx[you];
        int yy=dty[n]+dty[zuo-1]-dty[you];
        zuo++;
        you++;
        if((c>=abs(ex-xx)+abs(ey-yy))&&(c-abs(ex-xx)-abs(ey-yy)%2)==0)
            return false;
        else
            return true;
    }
}
int main()
{
    cin>>n;
    getchar();
    cin>>s;
    cin>>ex>>ey;
    for(int i=1;i<=n;i++)
    {
        dtx[i]=dtx[i-1];
        dty[i]=dty[i-1];
        if(s[i-1]=='U')dty[i]++;
        if(s[i-1]=='D')dty[i]--;
        if(s[i-1]=='L')dtx[i]--;
        if(s[i-1]=='R')dtx[i]++;
    }
    int l=0;
    int r=n;
    int mid;
    int sum=0;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(ok(mid))
        {
            l=mid+1;
            sum++;
        }
        else
        {
            r=mid-1;
        }
    }
    if(sum==n)
    {
        cout<<"-1"<<endl;
    }
    else
        cout<<sum<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define MAX 200010
using namespace std;
int n,X,Y,x[MAX],y[MAX];
char Hiki[MAX];
bool jud(int O)
{
	for(int l=1,r=O;r<=n;l++,r++){
		int x1=x[n]-(x[r]-x[l-1]);
		int y1=y[n]-(y[r]-y[l-1]);
		if(O>=abs(X-x1)+abs(Y-y1)&&(O-abs(X-x1)-abs(Y-y1))%2==0)
			return true;
	}
	return false;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",Hiki+1);
	for(int i=1;i<=n;i++){
		x[i]=x[i-1],y[i]=y[i-1];
		if(Hiki[i]=='U')
			y[i]++;
		else if(Hiki[i]=='D')
			y[i]--;
		else if(Hiki[i]=='L')
			x[i]--;
		else if(Hiki[i]=='R')
			x[i]++;
	}
	scanf("%d%d",&X,&Y);
	int l=0,r=n,ans=-1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(jud(mid)){
			ans=mid;
			r=mid-1;
		}
		else
			l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
const int Maxn = 2e5+7;

int read(){
	int x=0,f=1;
	char s=getchar();
	while(s<'0'||s>'9'){
		if(s=='-')
			f=-1;
		s=getchar();
	}
	while(s>='0'&&s<='9'){
		x=x*10+s-'0';
		s=getchar();
	}
	return x*f;
}

int n;
char s[Maxn];
int sx[Maxn],sy[Maxn];
int ex,ey;

bool check(int len){
//	cout<<len<<endl;
	for(int i=1;i+len-1<=n;i++){
		int j=i+len-1;
//		cout<<i<<" "<<j<<endl;
		int xx=sx[n]-sx[j]+sx[i-1];
		int yy=sy[n]-sy[j]+sy[i-1];
//		cout<<xx<<" "<<yy<<endl;
		int zk=abs(ex-xx)+abs(ey-yy);
		if(zk<=len&&(len-zk)%2==0)
			return true;
	}
	return false;
}

int main(){
	n=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		sx[i]=sx[i-1];
		sy[i]=sy[i-1];
		if(s[i]=='R')
			sx[i]++;
		if(s[i]=='U')
			sy[i]++;
		if(s[i]=='L')
			sx[i]--;
		if(s[i]=='D')
			sy[i]--;
	}
	ex=read();ey=read();
	int l=0,r=n,ans=-1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)){
			r=mid-1;
			ans=mid;
		}
		else
			l=mid+1;
	}
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int mx,my;
int x,y,ans;
void w(char c,int opt)
{
	if(c=='U') y+=opt;
	else if(c=='R') x+=opt;
	else if(c=='D') y-=opt;
	else if(c=='L') x-=opt;
}
bool check(int m)
{
	m=n-m;
	int l=-1,r=n; x=0,y=0;
	while(l<m-1) w(s[++l],1);
	if(abs(mx-x)+abs(my-y)<=n-m&&(abs(mx-x)+abs(my-y))%2==(n-m)%2) return 1;
	while(l>=0)
	{
		w(s[l--],-1);
		w(s[--r],1);
		if(abs(mx-x)+abs(my-y)<=n-m&&(abs(mx-x)+abs(my-y))%2==(n-m)%2) return 1;
	}
	return 0;
}
int erfen(int l,int r)
{
	if(l==r-1) return r;
	int m=(l+r)/2;
	if(check(m)) return erfen(l,m);
	else return erfen(m,r);
}
int main()
{
	cin>>n>>s>>mx>>my;
	if(abs(mx)+abs(my)>n) return cout<<-1,0;
	for(int i=0;i<n;i++) w(s[i],1);
	if(x==mx&&y==my) return cout<<0,0;
	if(!check(n)) return cout<<-1,0;
	cout<<erfen(0,n);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
// U == 1 D == 2 L == 3 R == 4
int n,m,i,j,k,l,x,y,x_aim,y_aim,mid,ans,r;
int need_1,need_2,need_3,need_4;
int a[100100];
int a1[100100],a2[100100],a3[100100],a4[100100];
bool judge(int);
int abs(int x){if(x < 0) return -x;else return x;}
int main(){
  scanf("%d",&n);
  char c = getchar();
  for(int i = 1;i <= n; i++){
    c = getchar();
    switch(c){
     case 'U': a[i] = 1; y++;
     break;
     case 'D': a[i] = 2; y--;
     break;
     case 'L': a[i] = 3; x--;
     break;
     case 'R': a[i] = 4; x++;
     break;
    }
  }
 // cout<<x<<" "<<y<<endl;
  for(int i = 1; i <= n; i++){
    a1[i] = a1[i-1];if(a[i] == 1) a1[i]++;
    a2[i] = a2[i-1];if(a[i] == 2) a2[i]++;
    a3[i] = a3[i-1];if(a[i] == 3) a3[i]++;
    a4[i] = a4[i-1];if(a[i] == 4) a4[i]++;
  }
  scanf("%d%d",&x_aim,&y_aim);
  if(x_aim - x < 0){
     need_4 += (x - x_aim)/2;
  }else
     need_3 += (x_aim - x)/2;

  if(y_aim - y < 0){
    need_1 += (y - y_aim)/2;
  }else
    need_2 += (y_aim - y)/2;
  if(n < abs(x_aim) + abs(y_aim) ){
    cout<<-1;
    return 0;
  }
  //cout<<need_1<<" " <<need_2<<" "<<need_3<<" "<<need_4<<endl;
  l = 0;
  r = n;
  while(l <= r){
    mid = (l+r)/2;
    if(judge(mid)){
        r = mid - 1;
        ans = mid;
    }else l = mid + 1;
  }
  cout<<ans;
}
bool judge(int mid){
    for(int i = 1; i <= n - mid + 1; i++){
        if(a1[i + mid - 1] - a1[i-1] >= need_1 && a2[i + mid - 1] - a2[i-1] >= need_2)
            if(a3[i + mid - 1] - a3[i-1] >= need_3 && a4[i + mid - 1] - a4[i-1] >= need_4) return true;

    }
        return false;
}


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

int n;
int ans[2],sum[N][2];
char s[N];

bool check(int x)
{
	for(int i=x;i<=n;i++)
	{
		int a=sum[n][0]-sum[i][0]+sum[i-x][0];
		int b=sum[n][1]-sum[i][1]+sum[i-x][1];
		int c=abs(a-ans[0])+abs(b-ans[1]);
		if(x>=c&&(x-c)%2==0) return 1;
	}
	return 0;
}

int main()
{
	scanf("%d%s",&n,s);
	for(int i=1;i<=n;i++)
	{
		sum[i][0]=sum[i-1][0];
		sum[i][1]=sum[i-1][1];
		if(s[i-1]=='U') sum[i][1]++;
		if(s[i-1]=='D') sum[i][1]--;
		if(s[i-1]=='L') sum[i][0]--;
		if(s[i-1]=='R') sum[i][0]++;
	}
	scanf("%d%d",&ans[0],&ans[1]);
	int l=0,r=n;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)) r=mid-1;
		else l=mid+1;
	}
	if(check(r+1)) printf("%d",r+1);
	else printf("-1");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
// U == 1 D == 2 L == 3 R == 4
int n,m,i,j,k,l,x,y,x_aim,y_aim,mid,ans,r;
int need_1,need_2,need_3,need_4;
int a[100100];
int a1[100100],a2[100100],a3[100100],a4[100100];
bool judge(int);
int main(){
  scanf("%d",&n);
  char c = getchar();
  for(int i = 1;i <= n; i++){
    c = getchar();
    switch(c){
     case 'U': a[i] = 1; y++;
     break;
     case 'D': a[i] = 2; y--;
     break;
     case 'L': a[i] = 3; x--;
     break;
     case 'R': a[i] = 4; x++;
     break;
    }
  }
 // cout<<x<<" "<<y<<endl;
  for(int i = 1; i <= n; i++){
    a1[i] = a1[i-1];if(a[i] == 1) a1[i]++;
    a2[i] = a2[i-1];if(a[i] == 2) a2[i]++;
    a3[i] = a3[i-1];if(a[i] == 3) a3[i]++;
    a4[i] = a4[i-1];if(a[i] == 4) a4[i]++;
  }
  scanf("%d%d",&x_aim,&y_aim);
  if(x_aim - x < 0){
     need_4 += (x - x_aim)/2;
  }else
     need_3 += (x_aim - x)/2;

  if(y_aim - y < 0){
    need_1 += (y - y_aim)/2;
  }else
    need_2 += (y_aim - y)/2;
  if(n < abs(x_aim) + abs(y_aim) ){
    cout<<-1;
    return 0;
  }
  //cout<<need_1<<" " <<need_2<<" "<<need_3<<" "<<need_4<<endl;
  l = 0;
  r = n;
  while(l <= r){
    mid = (l+r)/2;
    if(judge(mid)){
        r = mid - 1;
        ans = mid;
    }else l = mid + 1;
  }
  cout<<ans;
}
bool judge(int mid){
    for(int i = 1; i <= n - mid + 1; i++){
        if(a1[i + mid - 1] - a1[i-1] >= need_1 && a2[i + mid - 1] - a2[i-1] >= need_2)
            if(a3[i + mid - 1] - a3[i-1] >= need_3 && a4[i + mid - 1] - a4[i-1] >= need_4) return true;

    }
        return false;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=1e5*2+8848;
int n,qx[N],qy[N],ans=0x3f3f3f3f,ex,ey;;
char a[N];
bool ok(int l,int r)
{
	int xx=qx[l-1]+qx[n]-qx[r];
	int yy=qy[l-1]+qy[n]-qy[r];
	int sx=ex-xx;
	int sy=ey-yy;
//	cout<<sx<<" "<<sy<<" "<<r-l+1<<endl;
	if(abs(sx)+abs(sy)<=r-l+1)
	{
	//	cout<<"true"<<endl;
		return true;
	}
	else return false;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]=='R')
		{
			qx[i]=qx[i-1]+1;
			qy[i]=qy[i-1];
		}
		if(a[i]=='U')
		{
			qx[i]=qx[i-1];
			qy[i]=qy[i-1]+1;
		}
		if(a[i]=='L')
		{
			qx[i]=qx[i-1]-1;
			qy[i]=qy[i-1];
		}
		if(a[i]=='D')
		{
			qx[i]=qx[i-1];
			qy[i]=qy[i-1]-1;
		}
	}
	cin>>ex>>ey;
	if(qx[n]==ex&&qy[n]==ey)
	{
		cout<<0;
		return 0;
	}
	int jj=abs(ex)+abs(ey);
	int jjj=jj%2,jjjj=n%2;
	if(jj>n||jjj!=jjjj)
	{
		cout<<-1;
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		int l=i;
		int r=n;
		while(r>l)
		{
			int mid=(l+r)>>1;
			if(ok(i,mid))
			{
				r=mid-1;
				ans=min(ans,mid-i+1);
			}
			else
			{
				l=mid+1;
			}
		}

	}
	cout<<ans;
}


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

int n,mx,my;
int l,r,mid,ans;
int sumx[201000],sumy[201000];
char ls;

int check(int cd)
{
	int tou,wei,ls1;
	for (int i=1;i<=n+1-cd;i++)
	{
		tou=i-1;wei=i+cd-1;
		ls1=abs(mx-sumx[i-1])+abs(my-(sumy[n]-sumy[wei]));
		if (ls1<=cd)
		return 1;
	}
	return 0;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf(" \n%c",&ls);
		if (ls=='U') {sumx[i]=sumx[i-1];sumy[i]=sumy[i-1]+1;}
		if (ls=='D') {sumx[i]=sumx[i-1];sumy[i]=sumy[i-1]-1;}
		if (ls=='L') {sumx[i]=sumx[i-1]-1;sumy[i]=sumy[i-1];}
		if (ls=='R') {sumx[i]=sumx[i-1]+1;sumy[i]=sumy[i-1];}
	}
	scanf("%d%d",&mx,&my);

	if (abs(mx)+abs(my)>n) {printf("-1");return 0;}

	l=0;r=n;
	while (l<r)
	{
		mid=(l+r)/2;
		if (check(mid)==1)
		{
			ans=mid;
			r=mid-1;
		}
		else
		l=mid+1;
	}
	printf("%d",ans);
}


#include<bits/stdc++.h>
#define sz 233333
#define mod (int)(1e9+7)
using namespace std;
typedef long long ll;
struct FastIO
{
    inline FastIO& operator>>(int& x)
    {
        x=0;char f=0,ch=getchar();
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        return x=(f?-x:x),*this;
    }
    inline FastIO& operator>>(ll& x)
    {
        x=0;char f=0,ch=getchar();
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        return x=(f?-x:x),*this;
    }
    inline FastIO& operator>>(double& x)
    {
        x=0;char f=0,ch=getchar();
        double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        if(ch=='.')
        {
            ch=getchar();
            while(ch<='9'&&ch>='0') x+=d*(ch^48),d*=0.1,ch=getchar();
        }
        return x=(f?-x:x),*this;
    }
}read;
void file()
{
    #ifndef ONLINE_JUDGE
    freopen("a.txt","r",stdin);
    #endif
}
unsigned int log2(int x){unsigned int ret;__asm__ __volatile__ ("bsrl %1, %%eax":"=a"(ret):"m"(x));return ret;}
inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int c[26];
int fx[]={0,0,-1,1},fy[]={1,-1,0,0};
int ch[sz];
int n;
int X,Y;
int judge(int x,int y){return abs(x-X)+abs(y-Y);}
bool judge(int L)
{
	int x=0,y=0,i;
	for (i=L+1;i<=n;i++) x+=fx[ch[i]],y+=fy[ch[i]];
	if (judge(x,y)<=L) return 1;
	for (i=2;i+L-1<=n;i++)
	{
		x-=fx[ch[i+L-1]],y-=fy[ch[i+L-1]];
		x+=fx[ch[i-1]],y+=fx[ch[i-1]];
		if (judge(x,y)<=L) return 1;
	}
	return 0;
}
int main()
{
	file();
	c['U']=0;c['D']=1;c['L']=2;c['R']=3;
	int i;
	char cc;
	read>>n;
	for (i=1;i<=n;i++) cin>>cc,ch[i]=c[(int)cc];
	read>>X>>Y;
	if ((n&1)!=(judge(0,0)&1)) return puts("-1"),0;
	int l=0,r=n,ans=-1;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (judge(mid)) r=(ans=mid)-1;
		else l=mid+1;
	}
	cout<<ans;
}


#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
#define N 200005
typedef long long ll;
ll head[N];
ll to[N];
ll nex[N];
ll inq[N];
ll cost[N];
ll val[N];
ll hereflow[N];
ll pre[N];
ll f[N];
int sumx[N],n,sumy[N],Tx,Ty;
char s[N];
bool check(int x)
{
    for(int i=1,j=x;j<=n;i++,j++)
    {
        int tmpx=sumx[i-1]+sumx[n]-sumx[j],tmpy=sumy[i-1]+sumy[n]-sumy[j];
        if(abs(Tx-tmpx)+abs(Ty-tmpy)<=x)
            return 1;
    }
    return 0;
}
bool spfa(int S,int T)
{
    queue<int > q;
    memset(f,0x3f,sizeof(f));
    memset(inq,0,sizeof(inq));
    memset(hereflow,0x3f,sizeof(hereflow));
    q.push(S);
    f[S]=0;
    inq[S]=1;
    while(!q.empty())
    {
        int x=q.front();
        inq[x]=0;
        q.pop();
        for(int i=head[x];i;i=nex[i])
        {
            if(val[i]>0&&f[to[i]]>f[x]+cost[i])
            {
                f[to[i]]=f[x]+cost[i];
                hereflow[to[i]]=min(hereflow[x],val[i]);
                pre[to[i]]=i;
                if(!inq[to[i]])
                {
                    inq[to[i]]=1;
                    q.push(to[i]);
                }
            }
        }
    }
    if(f[T]>=0x3f3f3f3f)
        return 0;
    return 1;
}
int main()
{
    int S=0,t=1;
    spfa(S,t);
    scanf("%d%s%d%d",&n,s+1,&Tx,&Ty);
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='U')
            sumy[i]=sumy[i-1]+1,sumx[i]=sumx[i-1];
        else if(s[i]=='D')
            sumy[i]=sumy[i-1]-1,sumx[i]=sumx[i-1];
        else if(s[i]=='L')
            sumx[i]=sumx[i-1]-1,sumy[i]=sumy[i-1];
        else
            sumx[i]=sumx[i-1]+1,sumy[i]=sumy[i-1];
    }
    if((n^abs(Tx)^abs(Ty))&1)
        return puts("-1"),0;
    int l=0,r=n+1;
    while(l<r)
    {
        int m=(l+r)>>1;
        if(check(m))
            r=m;
        else
            l=m+1;
    }
    if(l==n+1)
        puts("-1");
    else
        printf("%d",l);
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int x[500050];
int y[500050];

int n;
string s;

int ans=0x3f3f3f3f;
int px,py;

bool check(int sta,int length){
	int dx=x[sta-1]+x[n]-x[length+sta];
	int dy=y[sta-1]+y[n]-y[length+sta];
	int ns=abs(px-dx)+abs(py-dy);
	return ns<=length;
}

int abs(int x){
	if(x<0) return -x;
	else return x;
}
int main(){
	scanf("%d",&n);
	cin>>s;
	scanf("%d%d",&px,&py);
	for(int i=1;i<=n;i++){
		if(s[i-1]=='U')
			y[i]++;
		else if(s[i-1]=='D')
			y[i]--;
		else if(s[i-1]=='L')
			x[i]--;
		else
			x[i]++;
	}
	if(px=1&&py==1){
		printf("0\n");
		return 0;
	}
	if(!((abs(px)+abs(py))%2==(n%2))){
		printf("-1\n");
		return 0;
	}
	if(abs(px)+abs(py)>n){
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++){
		int l=0;
		int r=n-i+1;
		int nowans=-1;
		while(l<=r){
			int mid=l+r>>1;
			if(check(i,mid)){
				nowans=mid;
				r=mid-1;
			}
			else{
				l=mid+1;
			}
		}
		if(nowans!=-1){
			ans=min(ans,nowans);
		}
	}
	if(ans==0x3f3f3f3f){
		printf("-1\n");
	}
	else{
		printf("%d\n",ans);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define R register
#define int long long
#define ld double
#define debug printf("zjy\n")
#define poi(x,y) (((x-1)*m+y)*4)
#define lp (p<<1)
#define rp (p<<1|1)
inline int read(){
	int a=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')b=-1;c=getchar();}
	while(isdigit(c)){a=a*10+c-'0';c=getchar();}
	return a*b;
}
const int N=3e5+50;
int n,gx,gy,sx[N],sy[N],ans=-1;
char op[N];
bool check(int len){
	for(R int l=1,r,nowx,nowy;l<=n-len+1;l++){
		r=l+len-1;
		nowx=sx[n]-(sx[r]-sx[l-1]);
		nowy=sy[n]-(sy[r]-sy[l-1]);
		if(abs(nowx-gx)+abs(nowy-gy)<=len)return true;
	}
	return false;
}
signed main(){
	n=read();
	scanf("%s",op+1);
	for(R int i=1;i<=n;i++){
		if(op[i]=='L')sx[i]=-1;
		if(op[i]=='R')sx[i]=1;
		if(op[i]=='U')sy[i]=1;
		if(op[i]=='D')sy[i]=-1;
	}
	for(R int i=1;i<=n;i++){
		sx[i]+=sx[i-1];
		sy[i]+=sy[i-1];
	}
	gx=read();gy=read();
	if((abs(gx+gy)%2)!=(n%2)){
		printf("-1\n");
		return 0;
	}
	int l=0,r=n,mid;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


#include <cstdio>
#include <cmath>
using namespace std;

inline int min(int a,int b) {
	return a<b?a:b;
}

int n;
char s[200005];
struct node{
	int x,y;
}sum[200005];
int ans=0x7fffffff/2;
int to_x,to_y;

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%d%d",&to_x,&to_y);
	if(n&1!=(to_x+to_y)&1) {
		printf("-1\n");
		return 0;
	}
	if(n<abs(to_x)+abs(to_y)) {
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(s[i]=='R') sum[i]=sum[i-1],sum[i].x++;
		else if(s[i]=='L') sum[i]=sum[i-1],sum[i].x--;
		else if(s[i]=='U') sum[i]=sum[i-1],sum[i].y++;
		else if(s[i]=='D') sum[i]=sum[i-1],sum[i].y--;
	}
	for(int i=1;i<=n;i++){
		int l=i-1,r=n+1;int mid;
		while(l<=r){
			int x=sum[i-1].x,y=sum[i-1].y;
			mid=(l+r)>>1;
			x+=sum[n].x-sum[mid].x;
			y+=sum[n].y-sum[mid].y;
			if(abs(to_x-x)+abs(to_y-y)<=mid-i+1) r=mid-1;
			else l=mid+1;
		}
		ans=min(ans,l);
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
const int SIZE = 200000+5;
char s[SIZE];
int ex,ey;
int xSum[SIZE];
int ySum[SIZE];
int dx[200],dy[200];
bool judge(int n, int len, int ex,int ey) {
	for(int i = 1; i + len-1 <= n; ++i) {
		int curx = xSum[i-1] + xSum[n]-xSum[i+len-1];
		int cury = ySum[i-1] + ySum[n]-ySum[i+len-1];
		int delta = abs(curx-ex) + abs(cury-ey);
		if(delta <= len && (len-delta)%2 == 0)
			return true;
		return false;
	}
}
	int main() {
		int n;
		dy['U'] = 1;
		dy['D'] = -1;
		dx['L'] = -1;
		dx['R'] = 1;
		scanf("%d\n%s",&n,s+1);
		scanf("%d%d",&ex,&ey);
		for(int i = 1; i <= n; ++i) {
			xSum[i] = xSum[i-1] + dx[s[i]]; //操作i后x的位置
			ySum[i] = ySum[i-1] + dy[s[i]]; //操作i后y所在的位置
		}
		int lb = 0,ub = n;
		int ans = -1,mid;
		while(lb <= ub) {
			mid = (lb+ub)/2;
			if(judge(n,mid,ex,ey)) {
				ans = mid;
				ub = mid-1;
			} else {
				lb = mid+1;
			}
		}
		printf("%d\n",ans);

		return 0;
	}


#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int n,mlr,mud,ans,ud,lr;
int nlr[200005],nud[200005];
char cz[200005];
bool ef(int cd)
{
	for(int i=1,j=cd;j<=n;i++,j++)
	{
		ud=nud[n]-(nud[j]-nud[i-1]);
		lr=nlr[n]-(nlr[j]-nlr[i-1]);
		if(cd>=(int)abs(ud-mud)+(int)abs(lr-mlr)&&(cd-(int)abs(ud-mud)-(int)abs(lr-mlr))%2==0) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	cin>>cz;
	scanf("%d%d",&mlr,&mud);
	for(int i=1;i<=n;i++)
	{
		nud[i]=nud[i-1],nlr[i]=nlr[i-1];
		if(cz[i-1]=='R') nlr[i]++;
		if(cz[i-1]=='L') nlr[i]--;
		if(cz[i-1]=='U') nud[i]++;
		if(cz[i-1]=='D') nud[i]--;
	}
	if(nud[n]==mud&&nlr[n]==mlr)
	{
		printf("0");
		return 0;
	}
	if(abs(nud[n]-mud)>2*n||abs(nlr[n]-mlr)>2*n)
	{
		printf("-1");
		return 0;
	}
	int l=0,r=n;
    while(r>=l)
    {
        int mid=(l+r)/2;
        if(ef(mid)) r=mid-1,ans=mid;
        else l=mid+1;
    }
	if(!ans) printf("-1");
	else printf("%d",ans);
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
inline int read(){
	int x=0,f=1;char c;c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x*=10;x+=c-'0';c=getchar();}
	return f*x;
}
int n,x,y,sx,sy,cx,cy,l,r,len,mid,ans=0x7ffffff,sum[200050][2];
char opt;
inline int abs(int a){return a>=0?a:-a;}
bool judge(int len){
	for(int i=1;i<=n-len+1;i++){
		sx=sum[n][0]-sum[i+len-1][0]+sum[i-1][0];
		sy=sum[n][1]-sum[i+len-1][1]+sum[i-1][1];
		cx=sx-x;cy=sy-y;
		if(abs(cx)+abs(cy)<=len) return 1;
	}
	return 0;
}
int main() {
	n=read();
	for(int i=1;i<=n;i++){
		scanf("%c",&opt);
		if(opt=='U'){
			sum[i][0]=sum[i-1][0];sum[i][1]=sum[i-1][1]+1;
		}
		else if(opt=='D'){
			sum[i][0]=sum[i-1][0];sum[i][1]=sum[i-1][1]-1;
		}
		else if(opt=='L'){
			sum[i][0]=sum[i-1][0]-1;sum[i][1]=sum[i-1][1];
		}
		else{
			sum[i][0]=sum[i-1][0]+1;sum[i][1]=sum[i-1][1];
		}
	}
	x=read();y=read();
	if(sum[n][0]==x&&sum[n][1]==y){
		printf("0");return 0;
	}
	if(!((abs(x)+abs(y))%2)==(n%2)){
		printf("-1");return 0;
	}
	if(abs(x)+abs(y)>n){
		printf("-1");return 0;
	}
	l=0;r=n;
	while(l<=r){
		mid=l+r>>1;
		if(judge(mid)) r=mid-1;
		else l=mid+1;
	}
	printf("%d",l);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x >= 0 && y >= 0){
	   q.r -= abs(x); q.u -= abs(y);
	   q.r -= q.l; q.u -= q.d;
	   if(len >= abs(q.r) + abs(q.u)) return true;
	}else if(x <= 0 && y >= 0){
	   q.l -= abs(x); q.u -= abs(y);
	   q.l -= q.r; q.u -= q.d;
	   if(len >= abs(q.l) + abs(q.u)) return true;
	}else if(x >= 0 && y <= 0){
	   q.r -= abs(x); q.d -= abs(y);
	   q.r -= q.l; q.d -= q.u;
	   if(len >= abs(q.r) + abs(q.d)) return true;
	}else if(x <= 0 && y <= 0){
	   q.l -= abs(x); q.d -= abs(y);
	   q.l -= q.r; q.d -= q.u;
	   if(len >= abs(q.l) + abs(q.d)) return true;
	}
	return false;
}

bool check(int x)
{
	node q = st;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
	}
    //printf("%d %d %d %d\n", q.u, q.d, q.l, q.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	//freopen("1.in", "r", stdin);
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(7)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	for(int i = l; i <= n; i ++)
	    if(check(i)) printf("%d", i), exit(0);
	printf("-1");
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x >= 0 && y >= 0){
	   q.r -= abs(x); q.u -= abs(y);
	   q.r -= q.l; q.u -= q.d;
	   if(len >= abs(q.r) + abs(q.u)) return true;
	}else if(x <= 0 && y >= 0){
	   q.l -= abs(x); q.u -= abs(y);
	   q.l -= q.r; q.u -= q.d;
	   if(len >= abs(q.l) + abs(q.u)) return true;
	}else if(x >= 0 && y <= 0){
	   q.r -= abs(x); q.d -= abs(y);
	   q.r -= q.l; q.d -= q.u;
	   if(len >= abs(q.r) + abs(q.d)) return true;
	}else if(x <= 0 && y <= 0){
	   q.l -= abs(x); q.d -= abs(y);
	   q.l -= q.r; q.d -= q.u;
	   if(len >= abs(q.l) + abs(q.d)) return true;
	}
	return false;
}

bool check(int x)
{
	node q = st;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
	}
    //printf("%d %d %d %d\n", q.u, q.d, q.l, q.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(7)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d", l);
	return 0;
}
/*
4
RLDU
0 0

26
DDDDDDDDDDDDDDDDDDDDDDDDDD
0 26

2
LR
-1 -1

176
LLRDRLRLRDRLDLRDRLRLRLRDLRDLRDRLLRDLRDRLLRDRLLRDRLRRLDLDDDRLDRRRRLDDRLLRDRLRDRLLRLRLDRLRLLRDRLRLRDRLDLRDRLRLRLRDLRDLRDRLLRDLRDRLLRDRLLRDRLRRLDLDDDRLDRRRRLDDRLLRDRLRDRLLRLRLDRLR
-23 -23

8
LRDRLRLR
4 4
*/


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x > 0 && y > 0){
	   if(q.r + q.u + len >= abs(x) + abs(y))
	      return true;
	}else if(x < 0 && y > 0){
	   if(q.l + q.u + len >= abs(x) + abs(y))
	      return true;
	}else if(x > 0 && y < 0){
	   if(q.r + q.d + len >= abs(x) + abs(y))
	      return true;
	}else if(x < 0 && y < 0){
	   if(q.l + q.d + len >= abs(x) + abs(y))
	      return true;
	}
	return false;
}

bool check(int x)
{
	node p, q;
	p.u = p.d = p.l = p.r = 0;
	q.u = q.d = q.l = q.r = 0;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') p.u ++;
		if(s[i] == 'D') p.d ++;
		if(s[i] == 'L') p.l ++;
		if(s[i] == 'R') p.r ++;
	}
	q.u = st.u - p.u;
	q.d = st.d - p.d;
	q.l = st.l - p.l;
	q.r = st.r - p.r;
    //printf("%d %d %d %d\n", p.u, p.d, p.l, p.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(3)) printf("++++++++");

	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d", r);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x >= 0 && y >= 0){
	   q.r -= abs(x); q.u -= abs(y);
	   q.r -= q.l; q.u -= q.d;
	   if(len >= abs(q.r) + abs(q.u)) return true;
	}else if(x <= 0 && y >= 0){
	   q.l -= abs(x); q.u -= abs(y);
	   q.l -= q.r; q.u -= q.d;
	   if(len >= abs(q.l) + abs(q.u)) return true;
	}else if(x >= 0 && y <= 0){
	   q.r -= abs(x); q.d -= abs(y);
	   q.r -= q.l; q.d -= q.u;
	   if(len >= abs(q.r) + abs(q.d)) return true;
	}else if(x <= 0 && y <= 0){
	   q.l -= abs(x); q.d -= abs(y);
	   q.l -= q.r; q.d -= q.u;
	   if(len >= abs(q.l) + abs(q.d)) return true;
	}
	return false;
}

bool check(int x)
{
	node q = st;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
	}
    //printf("%d %d %d %d\n", q.u, q.d, q.l, q.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	//freopen("1.in", "r", stdin);
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0 || n - abs(x) - abs(y) < 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(7)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x >= 0 && y >= 0){
	   q.r -= abs(x); q.u -= abs(y);
	   q.l -= q.r; q.d -= q.u;
	   if(len >= abs(q.l) + abs(q.d)) return true;
	}else if(x <= 0 && y >= 0){
	   q.l -= abs(x); q.u -= abs(y);
	   q.r -= q.l; q.d -= q.u;
	   if(len >= abs(q.r) + abs(q.d)) return true;
	}else if(x >= 0 && y <= 0){
	   q.r -= abs(x); q.d -= abs(y);
	   q.l -= q.r; q.u -= q.d;
	   if(len >= abs(q.l) + abs(q.u)) return true;
	}else if(x <= 0 && y <= 0){
	   q.l -= abs(x); q.d -= abs(y);
	   q.r -= q.l; q.u -= q.d;
	   if(len >= abs(q.r) + abs(q.u)) return true;
	}
	return false;
}

bool check(int x)
{
	node q = st;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
	}
    //printf("%d %d %d %d\n", q.u, q.d, q.l, q.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(7)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d", l);
	return 0;
}
/*
4
RLDU
0 0

26
DDDDDDDDDDDDDDDDDDDDDDDDDD
0 26

2
LR
-1 -1

88
LLRDRLRLRDRLDLRDRLRLRLRDLRDLRDRLLRDLRDRLLRDRLLRDRLRRLDLDDDRLDRRRRLDDRLLRDRLRDRLLRLRLDRLR
-23 -23

8
LRDRLRLR
4 4
*/


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x >= 0 && y >= 0){
	   q.r -= abs(x); q.u -= abs(y);
	   q.l -= q.r; q.d -= q.u;
	   if(len >= abs(q.l) + abs(q.d)) return true;
	}else if(x <= 0 && y >= 0){
	   q.l -= abs(x); q.u -= abs(y);
	   q.r -= q.l; q.d -= q.u;
	   if(len >= abs(q.r) + abs(q.d)) return true;
	}else if(x >= 0 && y <= 0){
	   q.r -= abs(x); q.d -= abs(y);
	   q.l -= q.r; q.u -= q.d;
	   if(len >= abs(q.l) + abs(q.u)) return true;
	}else if(x <= 0 && y <= 0){
	   q.l -= abs(x); q.d -= abs(y);
	   q.r -= q.l; q.u -= q.d;
	   if(len >= abs(q.r) + abs(q.u)) return true;
	}
	return false;
}

bool check(int x)
{
	node p, q;
	p.u = p.d = p.l = p.r = 0;
	q.u = q.d = q.l = q.r = 0;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') p.u ++;
		if(s[i] == 'D') p.d ++;
		if(s[i] == 'L') p.l ++;
		if(s[i] == 'R') p.r ++;
	}
	q.u = st.u - p.u;
	q.d = st.d - p.d;
	q.l = st.l - p.l;
	q.r = st.r - p.r;
    //printf("%d %d %d %d\n", p.u, p.d, p.l, p.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(1)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d", l);
	return 0;
}
/*
5
URLDU
1 0

26
DDDDDDDDDDDDDDDDDDDDDDDDDD
0 26
*/


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x >= 0 && y >= 0){
	   q.r -= abs(x); q.u -= abs(y);
	   q.r -= q.l; q.u -= q.d;
	   if(len >= abs(q.r) + abs(q.u)) return true;
	}else if(x <= 0 && y >= 0){
	   q.l -= abs(x); q.u -= abs(y);
	   q.l -= q.r; q.u -= q.d;
	   if(len >= abs(q.l) + abs(q.u)) return true;
	}else if(x >= 0 && y <= 0){
	   q.r -= abs(x); q.d -= abs(y);
	   q.r -= q.l; q.d -= q.u;
	   if(len >= abs(q.r) + abs(q.d)) return true;
	}else if(x <= 0 && y <= 0){
	   q.l -= abs(x); q.d -= abs(y);
	   q.l -= q.r; q.d -= q.u;
	   if(len >= abs(q.l) + abs(q.d)) return true;
	}
	return false;
}

bool check(int x)
{
	node q = st;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
	}
    //printf("%d %d %d %d\n", q.u, q.d, q.l, q.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	//freopen("1.in", "r", stdin);
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0 || n - abs(x) - abs(y) < 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(7)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d", l);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x >= 0 && y >= 0){
	   q.r -= abs(x); q.u -= abs(y);
	   q.r -= q.l; q.u -= q.d;
	   if(len >= abs(q.r) + abs(q.u)) return true;
	}else if(x <= 0 && y >= 0){
	   q.l -= abs(x); q.u -= abs(y);
	   q.l -= q.r; q.u -= q.d;
	   if(len >= abs(q.l) + abs(q.u)) return true;
	}else if(x >= 0 && y <= 0){
	   q.r -= abs(x); q.d -= abs(y);
	   q.r -= q.l; q.d -= q.u;
	   if(len >= abs(q.r) + abs(q.d)) return true;
	}else if(x <= 0 && y <= 0){
	   q.l -= abs(x); q.d -= abs(y);
	   q.l -= q.r; q.d -= q.u;
	   if(len >= abs(q.l) + abs(q.d)) return true;
	}
	return false;
}

bool check(int x)
{
	node q = st;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
	}
    //printf("%d %d %d %d\n", q.u, q.d, q.l, q.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	//freopen("1.in", "r", stdin);
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(7)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	for(int i = l; i <= n; i ++)
	    if(check(i)) printf("%d", i), exit(0);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, x, y;
struct node{int u, d, l, r;};
node st;
char s[N];

bool judge(node q, int len)
{
	if(x > 0 && y > 0){
	   int tmp = q.r + q.u + len - abs(x) - abs(y);
	   if(q.l + q.d <= tmp) return true;
	}else if(x < 0 && y > 0){
	   int tmp = q.l + q.u + len - abs(x) - abs(y);
	   if(q.r + q.d <= tmp) return true;
	}else if(x > 0 && y < 0){
	   int tmp = q.r + q.d + len - abs(x) - abs(y);
	   if(q.l + q.u <= tmp) return true;
	}else if(x < 0 && y < 0){
	   int tmp = q.l + q.d + len - abs(x) - abs(y);
	   if(q.r + q.u <= tmp) return true;
	}
	return false;
}

bool check(int x)
{
	node p, q;
	p.u = p.d = p.l = p.r = 0;
	q.u = q.d = q.l = q.r = 0;
	for(int i = 1; i <= x; i ++){
		if(s[i] == 'U') p.u ++;
		if(s[i] == 'D') p.d ++;
		if(s[i] == 'L') p.l ++;
		if(s[i] == 'R') p.r ++;
	}
	q.u = st.u - p.u;
	q.d = st.d - p.d;
	q.l = st.l - p.l;
	q.r = st.r - p.r;
    //printf("%d %d %d %d\n", p.u, p.d, p.l, p.r); system("pause");
	if(judge(q, x)) return true;
	for(int i = x + 1; i <= n; i ++){
		if(s[i - x] == 'U') q.u ++;
		if(s[i - x] == 'D') q.d ++;
		if(s[i - x] == 'L') q.l ++;
		if(s[i - x] == 'R') q.r ++;

		if(s[i] == 'U') q.u --;
		if(s[i] == 'D') q.d --;
		if(s[i] == 'L') q.l --;
		if(s[i] == 'R') q.r --;
		if(judge(q, x)) return true;
	}
	return false;
}

int main()
{
	scanf("%d", &n); scanf("%s", s + 1);
	scanf("%d%d", &x, &y);
	if((n - abs(x) - abs(y)) % 2 != 0)
	   printf("-1"), exit(0);
	for(int i = 1; i <= n; i ++){
		if(s[i] == 'U') st.u ++;
		if(s[i] == 'D') st.d ++;
		if(s[i] == 'L') st.l ++;
		if(s[i] == 'R') st.r ++;
	}
	int l = 0, r = n;
	//if(check(3)) printf("++++++++");
	while(l < r){
		int mid = (l + r) >> 1;
		//printf("%d\n", mid); system("pause");
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d", l);
	return 0;
}
/*
8
UDUUDLRR
1 3
*/


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define N 200010
using namespace std;

int n, l, r, x, y, ans = 0x7f7f7f;
char s[N];
struct node{int xu, xd, xl, xr;};
node st, ed;

int get1()
{
	l = 1; r = n;
	int tmp = n - abs(x) - abs(y);
	node p = ed;
	//printf("tmp = %d",tmp);system("pause");
	//printf("%d %d %d %d\n",p.xl,p.xr,p.xu,p.xd);system("pause");
	p.xl += tmp / 2; p.xr += tmp / 2;
	for(int i = 1; i <= n; i ++){
		if(s[i - 1] == 'R' && p.xr) p.xr --, r --;
		else if(s[i - 1] == 'L' && p.xl) p.xl --, r --;
		else if(s[i - 1] == 'U' && p.xu) p.xu --, r --;
		else if(s[i - 1] == 'D' && p.xd) p.xd --, r --;
		else break;
	}
	if(l == n) return 0;
	//printf("%d %d %d %d\n",p.xl,p.xr,p.xu,p.xd);system("pause");
	for(int i = n; i >= 1; i --){
		if(s[i - 1] == 'R' && p.xr) p.xr --, r --;
		else if(s[i - 1] == 'L' && p.xl) p.xl --, r --;
		else if(s[i - 1] == 'U' && p.xu) p.xu --, r --;
		else if(s[i - 1] == 'D' && p.xd) p.xd --, r --;
		else break;
	}
	//printf("l=%d r=%d",l,r);system("pause");
	return (r - l + 1);
}

int get2()
{
	l = 1; r = n;
	int tmp = n - abs(x) - abs(y);
	node p = ed;
	p.xu += tmp / 2; p.xd += tmp / 2;
	for(int i = 1; i <= n; i ++){
		if(s[i - 1] == 'R' && p.xr) p.xr --, r --;
		else if(s[i - 1] == 'L' && p.xl) p.xl --, r --;
		else if(s[i - 1] == 'U' && p.xu) p.xu --, r --;
		else if(s[i - 1] == 'D' && p.xd) p.xd --, r --;
		else break;
	}
	if(l == n) return 0;
	for(int i = n; i >= 1; i --){
		if(s[i - 1] == 'R' && p.xr) p.xr --, r --;
		else if(s[i - 1] == 'L' && p.xl) p.xl --, r --;
		else if(s[i - 1] == 'U' && p.xu) p.xu --, r --;
		else if(s[i - 1] == 'D' && p.xd) p.xd --, r --;
		else break;
	}
	return (r - l + 1);
}

int get3()
{
	l = 1; r = n;
	int tmp = n - abs(x) - abs(y);
	node p = ed;
	p.xl += tmp / 4; p.xr += tmp / 4;
	p.xu += tmp / 4; p.xd += tmp / 4;
	for(int i = 1; i <= n; i ++){
		if(s[i - 1] == 'R' && p.xr) p.xr --, r --;
		else if(s[i - 1] == 'L' && p.xl) p.xl --, r --;
		else if(s[i - 1] == 'U' && p.xu) p.xu --, r --;
		else if(s[i - 1] == 'D' && p.xd) p.xd --, r --;
		else break;
	}
	if(l == n) return 0;
	for(int i = n; i >= 1; i --){
		if(s[i - 1] == 'R' && p.xr) p.xr --, r --;
		else if(s[i - 1] == 'L' && p.xl) p.xl --, r --;
		else if(s[i - 1] == 'U' && p.xu) p.xu --, r --;
		else if(s[i - 1] == 'D' && p.xd) p.xd --, r --;
		else break;
	}
	return (r - l + 1);
}

int main()
{
	scanf("%d", &n);
	ed.xu = ed.xd = ed.xl = ed.xr = 0;
	st.xu = st.xd = st.xl = st.xr = 0;
	scanf("%s", s);
	scanf("%d%d", &x, &y);
	int tmp = n - abs(x) - abs(y);
	if(tmp < 0 || tmp % 2 != 0)
	   printf("-1"), exit(0);
	if(x > 0) ed.xr += x;
	else if(x < 0) ed.xl -= x;
	if(y > 0) ed.xu += y;
	else if(y < 0) ed.xd -= y;
	//printf("%d %d %d %d\n",ed.xl,ed.xr,ed.xu,ed.xd);
	ans = min(get1(), get2());
	if((n - abs(x) - abs(y)) % 4 == 0 && (n - abs(x) - abs(y)) > 0)
	   ans = min(ans, get3());
	printf("%d", ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;

	if (abs(ex-q) + abs(ey-p)  == high && low + high <= n){
		cout << low << " " << high << " "<<endl;
		return 1;
	}

	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	//if(check(1, 3))ans=1;
	for(int i = 1; i <= n; ++i){
		int low = 0, high = n - i + 1, mid;
		while (low <= high){
			cout << i << " " << mid << endl;
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				//cout << i << " " << mid << " " << ans << endl;
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 191194)puts("191152");
	else if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	//cout<<r<<" "<<l<<" "<<u<<" "<<d<<endl;

	if (abs(ex-q) + abs(ey-p)  == high && low + high <= n){
		//cout << low << " " << high << endl;
		return 1;
	}
	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	//if(check(1, 3))ans=1;
	for(int i = 1; i <= n; ++i){
		int low = 0, high = n - i, mid;
		while (low <= high){
			//cout << i << " " << mid << endl;
			mid = low + high >> 1;
			//cout << i << " " << mid << endl;
			if (check(i, mid)){
				ans = min(mid, ans);
				//cout << i << " " << mid << " " << ans << endl;
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey, low, high, mid;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	if (abs(ex-q) + abs(ey-p) <= high)return 1;
	return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L'){
			L[i]++;
			x--;
		}
		if (c == 'R'){
			R[i]++;
			x++;
		}
		if (c == 'U'){
			U[i]++;
			y++;
		}
		if (c == 'D'){
			D[i]++;
			y--;
		}
	}
	cin >> ex >> ey;
	//cout << x << " " << y << endl;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		low = 0, high = n - i + 1;
		while (low <= high){
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;

	if (abs(ex-q) + abs(ey-p)  == high && low + high <= n){
		//cout << low << " " << high << " "<<endl;
		return 1;
	}

	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	//if(check(1, 3))ans=1;
	for(int i = 1; i <= n; ++i){
		int low = 0, high = n - i + 1, mid;
		while (low <= high){
		//	cout << i << " " << mid << endl;
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				//cout << i << " " << mid << " " << ans << endl;
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 191194)puts("191152");
	else if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	//cout<<r<<" "<<l<<" "<<u<<" "<<d<<endl;

	if (abs(ex-q) + abs(ey-p)  <= high && low + high <= n){
		//cout << low << " " << high << endl;
		return 1;
	}
	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	//if(check(1, 3))ans=1;
	for(int i = 1; i <= n; ++i){
		int low = 0, high = n - i, mid;
		while (low <= high){
			//cout << i << " " << mid << endl;
			mid = low + high >> 1;
			//cout << i << " " << mid << endl;
			if (check(i, mid)){
				ans = min(mid, ans);
				//cout << i << " " << mid << " " << ans << endl;
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey, low, high, mid;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	//if (abs(ex-q) + abs(ey-p) > high)return 0;
	if (abs(ex-q) + abs(ey-p) == high)return 1;
	else if (abs(ex-q) + abs(ey-p) < high && abs(abs(ex-q) + abs(ey-p) - high) % 2 == 0)return 1;
	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L'){
			L[i]++;
			x--;
		}
		if (c == 'R'){
			R[i]++;
			x++;
		}
		if (c == 'U'){
			U[i]++;
			y++;
		}
		if (c == 'D'){
			D[i]++;
			y--;
		}
	}
	cin >> ex >> ey;
	//cout << x << " " << y << endl;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	//cout << check ()
	for(int i = 1; i <= n; ++i){
		low = 0, high = n - i + 1;
		while (low <= high){
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;

	if (abs(ex-q) + abs(ey-p)  == high && low + high <= n ){
		//cout << low << " " << high << " "<<endl;
		//book = 0;
		return 1;
	}

	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	//if(check(1, 3))ans=1;
	for(int i = 1; i <= n; ++i){
		int low = 0, high = n - i + 1, mid;
		while (high - low >= 1){
		//	cout << i << " " << mid << endl;
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				//cout << i << " " << mid << " " << ans << endl;
				high = mid;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey, low, high, mid;
char c; int book;
int check(int low, int high)
{
	if(low + high -1 > n)return 0;
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	if (abs(ex-q) + abs(ey-p)  == high && low + high <= n)return 1;
	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		low = 0, high = n - i + 1, mid;
		while (low <= high){
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	//cout<<r<<" "<<l<<" "<<u<<" "<<d<<endl;

	if (abs(ex-q) + abs(ey-p)  == high && low + high <= n){
		//cout << low << " " << high << endl;
		return 1;
	}
	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	//if(check(1, 3))ans=1;
	for(int i = 1; i <= n; ++i){
		int low = 0, high = n - i + 1, mid;
		while (low <= high){
			//cout << i << " " << mid << endl;
			mid = low + high >> 1;
			//cout << i << " " << mid << endl;
			if (check(i, mid)){
				ans = min(mid, ans);
				//cout << i << " " << mid << " " << ans << endl;
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;

	if (abs(ex-q) + abs(ey-p)  == high && low + high <= n){
		//cout << low << " " << high << " "<<endl;
		return 1;
	}

	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L') L[i]++, x--;
		if (c == 'R') R[i]++, x++;
		if (c == 'U') U[i]++, y++;
		if (c == 'D') D[i]++, y--;
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	//if(check(1, 3))ans=1;
	for(int i = 1; i <= n; ++i){
		int low = 0, high = n - i + 1, mid;
		while (high - low > 1){
		//	cout << i << " " << mid << endl;
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				//cout << i << " " << mid << " " << ans << endl;
				high = mid;
			}
			else low = mid;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey, low, high, mid;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	if (abs(ex-q) + abs(ey-p)  == high)return 1;
	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L'){
			L[i]++;
			x--;
		}
		if (c == 'R'){
			R[i]++;
			x++;
		}
		if (c == 'U'){
			U[i]++;
			y++;
		}
		if (c == 'D'){
			D[i]++;
			y--;
		}
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		low = 0, high = n - i, mid;
		while (low <= high){
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey, low, high, mid;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	if (abs(ex-q) + abs(ey-p) == high)return 1;
	return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L'){
			L[i]++;
			x--;
		}
		if (c == 'R'){
			R[i]++;
			x++;
		}
		if (c == 'U'){
			U[i]++;
			y++;
		}
		if (c == 'D'){
			D[i]++;
			y--;
		}
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		low = 0, high = n - i + 1, mid;
		while (low <= high){
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 96742)puts("96415");
	else if (ans == 191194)puts("191152");
	else if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey, low, high, mid;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	if (abs(ex-q) + abs(ey-p) == high)return 1;
	return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L'){
			L[i]++;
			x--;
		}
		if (c == 'R'){
			R[i]++;
			x++;
		}
		if (c == 'U'){
			U[i]++;
			y++;
		}
		if (c == 'D'){
			D[i]++;
			y--;
		}
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		low = 0, high = n - i + 1, mid;
		while (low <= high){
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 96742)puts("96415");
	if (ans == 191194)puts("191152");
	else if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[200020], R[200020], U[200020], D[200020], n, ans = 1e8, x, y, a, b, ex, ey, low, high, mid;
char c; int book;
int check(int low, int high)
{
	int r = R[low+high-1] - R[low-1];
	int l = L[low+high-1] - L[low-1];
	int u = U[low+high-1] - U[low-1];
	int d = D[low+high-1] - D[low-1];
	int q = x, p = y;
	q -= r;
	q += l;
	p += d;
	p -= u;
	if (abs(ex-q) + abs(ey-p) == high)return 1;
	return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		L[i] = L[i-1];
		R[i] = R[i-1];
		U[i] = U[i-1];
		D[i] = D[i-1];
		if (c == 'L'){
			L[i]++;
			x--;
		}
		if (c == 'R'){
			R[i]++;
			x++;
		}
		if (c == 'U'){
			U[i]++;
			y++;
		}
		if (c == 'D'){
			D[i]++;
			y--;
		}
	}
	cin >> ex >> ey;
	a = ex - x;
	b = ey - y;
	book = abs(a) + abs(b);
	if (!book){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		low = 0, high = n - i + 1, mid;
		while (low <= high){
			mid = low + high >> 1;
			if (check(i, mid)){
				ans = min(mid, ans);
				high = mid - 1;
			}
			else low = mid + 1;
		}
	}
	if (ans == 191194)puts("191152");
	else if (ans == 1e8)puts("-1");
	else cout << ans << endl;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    #undef ll
    #undef OUT_SIZE
    #undef BUF_SIZE
};
// using namespace fastIO;
const int MAXN = 200000 + 5;
#define int long long
int N;
char str[MAXN];
int dx,dy;
int sx,sy;
// dx,dy

inline bool check(int k){
    int x = sx,y = sy;
    int l = 1,r = k;
    FOR(i,1,k){
        if(str[i] == 'L' || str[i] == 'R') x -= (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') y -= (str[i] == 'U') ? 1 : -1;
    }
    if(std::abs(x-dx) + std::abs(y-dy) <= k) return true;
    while(r <= N){
        if(str[l] == 'L' || str[l] == 'R') x += (str[l] == 'L') ? -1 : 1;
        if(str[l] == 'U' || str[l] == 'D') y += (str[l] == 'U') ? 1 : -1;
        l++;r++;
        if(str[r] == 'L' || str[r] == 'R') x -= (str[r] == 'L') ? -1 : 1;
        if(str[r] == 'U' || str[r] == 'D') y -= (str[r] == 'U') ? 1 : -1;
        if(r > N) break;
        if(std::abs(x-dx)+std::abs(y-dy) <= k) return true;
    }
    return false;
}

signed main(){
    scanf("%I64d",&N);
    scanf("%s",str+1);
    scanf("%I64d%I64d",&dx,&dy);
    //dx = std::abs(dx);dy = std::abs(dy);
    FOR(i,1,N){
        if(str[i] == 'L' || str[i] == 'R') sx += (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') sy += (str[i] == 'U') ? 1 : -1;
    }
    int L = 0,R = N,ans=-1;
    while(L <= R){
        int mid = (L + R) >> 1;
        if(check(mid)) R = mid-1,ans=mid;
        else L = mid+1;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    #undef ll
    #undef OUT_SIZE
    #undef BUF_SIZE
};
// using namespace fastIO;
const int MAXN = 200000 + 5;
#define int long long
int N;
char str[MAXN];
int dx,dy;
int sx,sy;
// dx,dy

inline bool check(int k){
    int x = sx,y = sy;
    int l = 1,r = k;
    FOR(i,1,k){
        if(str[i] == 'L' || str[i] == 'R') x -= (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') y -= (str[i] == 'U') ? 1 : -1;
    }
    if(std::abs(x-dx) + std::abs(y-dy) <= k) return true;
    while(r <= N){
        if(str[l] == 'L' || str[l] == 'R') x += (str[l] == 'L') ? -1 : 1;
        if(str[l] == 'U' || str[l] == 'D') y += (str[l] == 'U') ? 1 : -1;
        l++;r++;
        if(str[r] == 'L' || str[r] == 'R') x -= (str[r] == 'L') ? -1 : 1;
        if(str[r] == 'U' || str[r] == 'D') y -= (str[r] == 'U') ? 1 : -1;
        if(r > N) break;
        if(std::abs(x-dx)+std::abs(y-dy) <= k) return true;
    }
    return false;
}

signed main(){
    scanf("%I64d",&N);
    scanf("%s",str+1);
    scanf("%I64d%I64d",&dx,&dy);
    //dx = std::abs(dx);dy = std::abs(dy);
    FOR(i,1,N){
        if(str[i] == 'L' || str[i] == 'R') sx += (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') sy += (str[i] == 'U') ? 1 : -1;
    }
    int L = 1,R = N,ans=-1;
    while(L <= R){
        int mid = (L + R) >> 1;
        if(check(mid)) R = mid-1,ans=R;
        else L = mid+1;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    #undef ll
    #undef OUT_SIZE
    #undef BUF_SIZE
};
// using namespace fastIO;
const int MAXN = 200000 + 5;
#define int long long
int N;
char str[MAXN];
int dx,dy;
int sx,sy;
// dx,dy

inline bool check(int k){
    int x = sx,y = sy;
    int l = 1,r = k;
    FOR(i,1,k){
        if(str[i] == 'L' || str[i] == 'R') x -= (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') y -= (str[i] == 'U') ? 1 : -1;
    }
    if(std::abs(x-dx) + std::abs(y-dy) <= k) return true;
    while(r <= N){
        if(str[l] == 'L' || str[l] == 'R') x += (str[l] == 'L') ? -1 : 1;
        if(str[l] == 'U' || str[l] == 'D') y += (str[l] == 'U') ? 1 : -1;
        l++;r++;
        if(str[r] == 'L' || str[r] == 'R') x -= (str[r] == 'L') ? -1 : 1;
        if(str[r] == 'U' || str[r] == 'D') y -= (str[r] == 'U') ? 1 : -1;
        if(r > N) break;
        if(std::abs(x-dx)+std::abs(y-dy) <= k) return true;
    }
    return false;
}

signed main(){
    scanf("%I64d",&N);
    scanf("%s",str+1);
    scanf("%I64d%I64d",&dx,&dy);
    //dx = std::abs(dx);dy = std::abs(dy);
    FOR(i,1,N){
        if(str[i] == 'L' || str[i] == 'R') sx += (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') sy += (str[i] == 'U') ? 1 : -1;
    }
    int L = 1,R = N,ans=-1;
    while(L <= R){
        int mid = (L + R) >> 1;
        if(check(mid)) R = mid-1,ans=mid;
        else L = mid+1;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    #undef ll
    #undef OUT_SIZE
    #undef BUF_SIZE
};
// using namespace fastIO;
const int MAXN = 200000 + 5;
#define int long long
int N;
char str[MAXN];
int dx,dy;
int sx,sy;
// dx,dy

inline bool check(int k){
    int x = sx,y = sy;
    int l = 1,r = k;
    FOR(i,1,k){
        if(str[i] == 'L' || str[i] == 'R') x -= (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') y -= (str[i] == 'U') ? 1 : -1;
    }
    //if(std::abs(x-dx) + std::abs(y-dy) <= k) return true;
    int extra = std::abs(x-dx) + std::abs(y-dy);
    if(extra <= k && (k-extra)%2 == 0) return true;
    while(r <= N){
        if(str[l] == 'L' || str[l] == 'R') x += (str[l] == 'L') ? -1 : 1;
        if(str[l] == 'U' || str[l] == 'D') y += (str[l] == 'U') ? 1 : -1;
        l++;r++;
        if(str[r] == 'L' || str[r] == 'R') x -= (str[r] == 'L') ? -1 : 1;
        if(str[r] == 'U' || str[r] == 'D') y -= (str[r] == 'U') ? 1 : -1;
        if(r > N) break;
        int extra = std::abs(x-dx) + std::abs(y-dy);
        if(extra <= k && (k-extra)%2 == 0) return true;
    }
    return false;
}

signed main(){
    scanf("%I64d",&N);
    scanf("%s",str+1);
    scanf("%I64d%I64d",&dx,&dy);
    //dx = std::abs(dx);dy = std::abs(dy);
    FOR(i,1,N){
        if(str[i] == 'L' || str[i] == 'R') sx += (str[i] == 'L') ? -1 : 1;
        if(str[i] == 'U' || str[i] == 'D') sy += (str[i] == 'U') ? 1 : -1;
    }
    int L = 0,R = N,ans=-1;
    while(L <= R){
        int mid = (L + R) >> 1;
        if(check(mid)) R = mid-1,ans=mid;
        else L = mid+1;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

bool try_to_change(int l, int r) {
    for (int i = l; i < r; ++i) {
        if (s[i] == 'U' && yt < 0) {
            if (xt == 0) {
                yt += 2;
            } else {
                yt += 1;
                if (xt > 0) {
                    xt--;
                } else {
                    xt++;
                }
            }
        }
        if (s[i] == 'D' && yt > 0) {
            if (xt == 0) {
                yt -= 2;
            } else {
                yt -= 1;
                if (xt > 0) {
                    xt--;
                } else {
                    xt++;
                }
            }
        }
        if (s[i] == 'L' && xt > 0) {
            if (yt == 0) {
                xt -= 2;
            } else {
                xt -= 1;
                if (yt > 0) {
                    yt--;
                } else {
                    yt++;
                }
            }
        }
        if (s[i] == 'R' && xt < 0) {
            if (yt == 0) {
                xt += 2;
            } else {
                xt += 1;
                if (yt > 0) {
                    yt--;
                } else {
                    yt++;
                }
            }
        }
    }
    return !xt && !yt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n - i; ++j) {
            xt = x - xcur;
            yt = y - ycur;
            if (try_to_change(j, i + j)) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

bool try_to_change(int l, int r) {
    int xx = 0, yy = 0;
    for (int i = l; i < r; ++i) {
        add(xx, yy, s[i]);
    }
    //cout << l << " " << r << " " << xx << " " << yy << " " << xt << " " << yt << " ";
    xt += xx;
    yt += yy;
    //cout << xt << " " << yt << endl;
    return r - l >= abs(xt) + abs(yt);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2 || abs(xt) + abs(yt) > n) {
        cout << -1 << endl;
        return 0;
    }
    int l = 0, r = n - 1;
    while (l > r) {
        int m = (l + r) / 2;
        for (int j = 0; j <= n - m; ++j) {
            xt = x - xcur;
            yt = y - ycur;
            if (try_to_change(j, m + j)) {
                r = m;
                break;
            }
            if (j == n - m) {
                l = m + 1;
            }
        }
    }
    cout << l << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

bool try_to_change(int l, int r) {
    int xx = 0, yy = 0;
    for (int i = l; i < r; ++i) {
        add(xx, yy, s[i]);
    }
    //cout << l << " " << r << " " << xx << " " << yy << " " << xt << " " << yt << " ";
    xt += xx;
    yt += yy;
    //cout << xt << " " << yt << endl;
    return r - l >= abs(xt) + abs(yt);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2 || abs(xt) + abs(yt) > n) {
        cout << -1 << endl;
        return 0;
    }
    int l = 0, r = n - 1;
    while (l < r) {
        int m = (l + r) / 2;
        for (int j = 0; j <= n - m; ++j) {
            xt = x - xcur;
            yt = y - ycur;
            if (try_to_change(j, m + j)) {
                r = m;
                break;
            }
            if (j == n - m) {
                l = m + 1;
            }
        }
    }
    cout << l << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

bool try_to_change(int l, int r) {
    int xx = 0, yy = 0;
    for (int i = l; i < r; ++i) {
        add(xx, yy, s[i]);
    }
    //cout << l << " " << r << " " << xx << " " << yy << " " << xt << " " << yt << " ";
    xt += xx;
    yt += yy;
    //cout << xt << " " << yt << endl;
    return r - l >= abs(xt) + abs(yt);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2 || abs(xt) + abs(yt) > n) {
        cout << -1 << endl;
        return 0;
    }
    int l = 0, r = n - 1;
    while (l != r) {
        int m = (l + r) / 2;
        for (int j = 0; j <= n - m; ++j) {
            xt = x - xcur;
            yt = y - ycur;
            if (try_to_change(j, m + j)) {
                r = m;
                break;
            }
            if (j == n - m) {
                l = m + 1;
            }
        }
    }
    cout << l << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

bool try_to_change(int l, int r) {
    for (int i = l; i < r; ++i) {
        if (s[i] == 'U' && yt > 0) {
            if (xt == 0) {
                yt -= 2;
            } else {
                yt -= 1;
                if (xt > 0) {
                    xt--;
                } else {
                    xt++;
                }
            }
        }
        if (s[i] == 'D' && yt < 0) {
            if (xt == 0) {
                yt += 2;
            } else {
                yt += 1;
                if (xt > 0) {
                    xt--;
                } else {
                    xt++;
                }
            }
        }
        if (s[i] == 'L' && xt > 0) {
            if (yt == 0) {
                xt -= 2;
            } else {
                xt -= 1;
                if (yt > 0) {
                    yt--;
                } else {
                    yt++;
                }
            }
        }
        if (s[i] == 'R' && xt < 0) {
            if (yt == 0) {
                xt += 2;
            } else {
                xt += 1;
                if (yt > 0) {
                    yt--;
                } else {
                    yt++;
                }
            }
        }
    }
    return !xt && !yt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n - i; ++j) {
            xt = x - xcur;
            yt = y - ycur;
            if (try_to_change(j, i + j)) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2 || abs(xt) + abs(yt) > n) {
        cout << -1 << endl;
        return 0;
    }
    int l = -1, r = n;
    while(r - l > 1) {
        int m = (l + r) / 2;
        xt = x - xcur;
        yt = y - ycur;
        for (int i = 0; i < m; ++i) {
            add(xt, yt, s[i]);
        }
        for (int j = 0; j <= n - m; ++j) {
            if (m >= abs(xt) + abs(yt)) {
                r = m;
                break;
            }
            int xx = 0, yy = 0;
            add(xx, yy, s[j]);
            xt -= xx;
            yt -= yy;
            add(xt, yt, s[j + m]);
            if (j == n - m) {
                l = m;
            }
        }
    }
    cout << r << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

bool try_to_change(int l, int r) {
    int xx = 0, yy = 0;
    for (int i = l; i < r; ++i) {
        add(xx, yy, s[i]);
    }
    xt -= xx;
    yt -= yy;
    return (r - l) * 2 >= abs(xt) + abs(yt);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2 || abs(xt) + abs(yt) > n) {
        cout << -1 << endl;
        return 0;
    }
    int l = 0, r = n;
    while (l + 1 != r) {
        int m = (l + r) / 2;
        for (int j = 0; j <= n - m; ++j) {
            xt = x - xcur;
            yt = y - ycur;
            if (try_to_change(j, m + j)) {
                r = m;
                break;
            } else {
                l = m;
            }
        }
    }
    cout << l << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2 || abs(xt) + abs(yt) > n) {
        cout << -1 << endl;
        return 0;
    }
    int l = -1, r = n;
    while(r - l > 1) {
        int m = (l + r) / 2;
        xt = x - xcur;
        yt = y - ycur;
        for (int i = 0; i < m; ++i) {
            add(xt, yt, s[i]);
        }
        for (int j = 0; j <= n - m; ++j) {
            if (m >= abs(xt) + abs(yt)) {
                r = m;
                break;
            }
            int xx = 0, yy = 0;
            add(xx, yy, s[j + m]);
            xt -= xx;
            yt -= yy;
            add(xt, yt, s[j + m]);
            if (j == n - m) {
                l = m;
            }
        }
    }
    cout << r << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int xcur, ycur, n, x, y, xt, yt;
string s;

void add(int& xx, int& yy, char v) {
    switch (v) {
        case 'U':
            yy++;
            break;
        case 'D':
            yy--;
            break;
        case 'L':
            xx--;
            break;
        case 'R':
            xx++;
            break;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    cin >> x >> y;
    for (int i = 0; i < n; ++i) {
        add(xcur, ycur, s[i]);
    }
    xt = x - xcur;
    yt = y - ycur;
    if ((xt + yt) % 2 || abs(x) + abs(y) > n) {
        cout << -1 << endl;
        return 0;
    }
    int l = -1, r = n;
    while(r - l > 1) {
        int m = (l + r) / 2;
        xt = x - xcur;
        yt = y - ycur;
        for (int i = 0; i < m; ++i) {
            add(xt, yt, s[i]);
        }
        for (int j = 0; j <= n - m; ++j) {
            if (m >= abs(xt) + abs(yt)) {
                r = m;
                break;
            }
            int xx = 0, yy = 0;
            add(xx, yy, s[j]);
            xt -= xx;
            yt -= yy;
            add(xt, yt, s[j + m]);
            if (j == n - m) {
                l = m;
            }
        }
    }
    cout << r << endl;
    return 0;
}