// author : lynmisakura
// TIMESTAMP: 2020-10-17, 20:07:37

#include<bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i = 0;i < n;i++)
#define RNG(i,s,n) for(int i = s;i < n;i++)
#define _RNG(i,s,e) for(int i=s;i>=e;i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define dup(x,y) (x + y - 1) / (y)
#define all(x) (x).begin(),(x).end()
#define lb(x,key) lower_bound(all(x) , (key))
#define ub(x,key) upper_bound(all(x) , (key))

template<class T> bool chmax(T& a,T b){ if(a < b){ a = b; return true; }else return false; }
template<class T> bool chmin(T& a,T b){ if(a > b){ a = b; return true; }else return false; }

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;

#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout<<"["<<#a<<","<<#b<<"] = "<<"["<<a<<","<<b<<"]\n"
#define debug3(a,b,c) cout<<"["<<#a<<","<<#b<<","<<#c<<"] = "<<"["<<a<<","<<b<<","<<c<<"]\n"
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
  cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
  return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
  cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
  return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
  for (auto& i : arr)cin >> i; return in;
}
template<class S,class T> istream &operator >> (istream& in,pair<S,T>& p){
  cin >> p.first >> p.second; return in;
}

#define F first
#define S second
/////////////////////////////////////////////////////////////////////////

ll x,y,a,b;
ll ans;
map<ll,ll> M;
int cnt = 0;
void dfs(ll tmp,ll cur = 0){
  //if(cnt++ <= 20) cout << tmp << ' ' << cur << endl;

  if(tmp >= y){
    return;
  }
  
  chmax(ans , cur + (y - 1 - tmp) / b);

  if((y / tmp) <= x) return;
  if(!M.count(a * tmp) || (M[a * tmp] < cur + 1)){
    M[a * tmp] = cur + 1;
    dfs(a * tmp , cur + 1);
  }
  
  //if(!M.count(b + tmp) || (M[b + tmp] < cur + 1)){
  //  M[b + tmp] = cur + 1;
  //  dfs(b + tmp , cur + 1);
  //}

}
int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(20);
  
  cin >> x >> y >> a >> b;
  dfs(x);
  cout << ans << '\n';

  return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define  jx 1000000
char s[100001];
int len,f[26];
int main(){
	cin>>len;
	scanf("%s",s);
	fo(i,0,25)f[i]=jx;
	f[s[0]-'a']=0;
	if(len==1){
		printf("-1");
		return 0;
	}
	fo(i,1,len-2){
		int u=jx;
		fo(j,0,25){
			if(j!=(s[i]-'a'))u=min(u,f[j]+1);
		}
		f[s[i+1]-'a']=min(u,f[s[i+1]-'a']);
	}
	int u=jx;
	fo(j,0,25){
		if(j!=(s[len-1]-'a'))u=min(u,f[j]+1);
	}
	if(u>=jx)printf("-1");
	else printf("%d",u);
	return 0;
}