#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
int main(){
    int n;
    cin>>n;
    V<ll> l(n),r(n);
    for(int i=0;i<2*n;i++){
         if(i<n)cin>>l[i];
         else cin>>r[i-n];
    }
    reverse(all(l));
    ll ans=-inf,res=0;
    priority_queue<ll,V<ll>,greater<ll>> a,b;
    a.emplace(l[0]);
    for(int i=1;i<n;i++){
        a.emplace(l[i]);
        b.emplace(r[i]);
        if(a.top()<b.top()){
              a.pop();
        }else{
             b.pop();
        }
    }
    while(a.size()){
          res+=a.top();
          a.pop();
    }
    while(b.size()){
          res+=b.top();
          b.pop();
    }
    ans=res;
    res=0;
    b.emplace(r[0]);
    for(int i=1;i<n;i++){
        a.emplace(l[i]);
        b.emplace(r[i]);
        if(a.top()<b.top()){
              a.pop();
        }else{
             b.pop();
        }
    }
    while(a.size()){
          res+=a.top();
          a.pop();
    }
    while(b.size()){
          res+=b.top();
          b.pop();
    }
    cout<<max(ans,res)<<"\n";
}
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i=0; i<(int)(n); i++)
#define REP(i, n) for (int i=1; i<=(int)(n); i++)
#define For(i, n, m) for (int i=(n); i<=(int)(m); i++)
#define ll long long
const ll INF=1LL<<60;

int main() {
    string S;
    cin >> S;
    vector<int> a,b,c;
    Rep(i,S.size()) {
        char s=S.at(i);
        if (s=='o') a.push_back(i);
        if (s=='x') b.push_back(i);
        if (s=='?') c.push_back(i);
    }
    int cnt = 0;
    Rep(i,10) {
        bool no=false;
        Rep(I,b.size()) if(i==b.at(I)) no = true;
        if (no) continue;
        Rep(j,10) {
        bool no=false;
            Rep(I,b.size()) if(j==b.at(I)) no = true;
            if (no) continue;
            Rep(k,10) {
            bool no=false;
                Rep(I,b.size()) if(k==b.at(I)) no = true;
                if (no) continue;
                Rep(l,10) {
                    bool no=false;
                    Rep(I,b.size()) if(l==b.at(I)) no = true;
                    if (no) continue;
                    bool can=true;
                    Rep(I,a.size()) {
                        if (i!=a.at(I) && j!=a.at(I) && k!=a.at(I)&& l!=a.at(I)) can = false;
                    }
                    if (can) cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}