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

vector<long long> A, B;

int main() {
    long long int n;
    cin >> n;
    long long A = 3ll;
    while (true) {
        if (n <= A)
            break;
        long long m = n - A;
        while (m % 5 == 0) {
            m /= 5;
        }
        if (m == 1) {
            int cnt = 0;
            m = A;
            while (m % 3 == 0) {
                m /= 3;
                cnt++;
            }
            int cnt2 = 0;
            m = n - A;
            while (m % 5 == 0) {
                m /= 5;
                cnt2++;
            }
            if (cnt >= 1 && cnt2 >= 1) {
                cout << cnt << " " << cnt2 << "\n";
                return 0;
            }
        }
        long long B = A * 3ll;
        if (B < A)
            break;
        A = B;
    }
    cout << "-1\n";
}

#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <climits>

#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<vl> dp(n + 1, vl(2));
  dp[0][0] = dp[0][1] = 1;
  rep(i, n){
    string s;
    cin >> s;
    if(s == "OR"){
      dp[i + 1][1] = dp[i][0] + dp[i][1] * 2;
      dp[i + 1][0] = dp[i][0];
    }else{
      dp[i + 1][1] = dp[i][1];
      dp[i + 1][0] = dp[i][0] * 2 + dp[i][1];
    }
  }
  cout << dp[n][1] << endl;
}