//ΔAGC053B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 444444;
int n,a[N];
priority_queue<int,vector<int>,greater<int> > Q;
int main()
{
	int i,x,y;
	LL s=0;
	scanf("%d",&n);
	for(i=1;i<=n*2;i=i+1)
		scanf("%d",a+i);
	for(i=1;i<=n;i=i+1){
		x=a[n+i],y=a[n-i+1];
		if(x<y)
			swap(x,y);
		Q.push(x);
		if(Q.top()<y){
			Q.pop();
			Q.push(y);
		}
	}
	while(!Q.empty()){
		s+=Q.top();
		Q.pop();
	}
	cout<<s;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

bool check(string S, string pass) {
  vector<bool> b(10, false);

  b.at(pass.at(0) - '0') = true;
  b.at(pass.at(1) - '0') = true;
  b.at(pass.at(2) - '0') = true;
  b.at(pass.at(3) - '0') = true;

  for (int i = 0; i < 10; i++) {
    if (S.at(i) == 'o' && b.at(i) == false)
      return false;
    if (S.at(i) == 'x' && b.at(i) == true)
      return false;
  }

  return true;
}

int main() {
  int ans = 0;
  string S;
  cin >> S;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 10; l++) {
          string pass;
          pass += i + '0';
          pass += j + '0';
          pass += k + '0';
          pass += l + '0';
          if (check(S, pass))
            ans++;
        }
      }
    }
  }

  cout << ans << endl;
}