

// Fearless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long>
#define PI (2.0 * acos(0.0))
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define info pair<int, pii>
#define mkp make_pair
const long long M = 1e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;
void solve () {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << fixed << setprecision(10) << 1.0 * (c * b + a * d) / (b + d + 0.0) << endl;
}
int main () {
    //freopen("E:/newts/in.txt", "r", stdin);
    //freopen("E:/newts/out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //testcase {
        solve ();
    //}
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  if (N <= 3) {
    cout << 1 << endl;
    return 0;
  }
  
  char caa, cab, cba, cbb;
  cin >> caa >> cab >> cba >> cbb;
  
  if (caa == 'A' && cab == 'A') cout << 1 << endl;
  else if (cab == 'B' && cbb == 'B') cout << 1 << endl;
  else if (caa == 'B' && cab == 'A' && cba == 'A') {
    int count = 1, count2 = 1, count3 = 1 ;
    for (int i = 3; i < N; i++) {
      count = (count2 + count3) % 1000000007;
      count3 = count2;
      count2 = count;
    }
    cout << count << endl;
  }
  else if (cab == 'B' && cba == 'B' && cbb == 'A') {
    int count = 1, count2 = 1, count3 = 1 ;
    for (int i = 3; i < N; i++) {
      count = (count2 + count3) % 1000000007;
      count3 = count2;
      count2 = count;
    }
    cout << count << endl;
  }
  else {
    int count = 1;
    for (int i = 3; i < N; i++) {
      count = (count * 2) % 1000000007;
    }
    cout << count << endl;
  }
  
  
  
    
return 0;
}