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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s.at(i);
  
  vector<vector<ll>> dp(n + 1, vector<ll>(2)); // T, F
  dp[0][0] = dp[0][1] = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == "AND") {
      dp[i + 1][0] += dp[i][0];
      dp[i + 1][1] += dp[i][0] + dp[i][1] * 2;
    }
    else {
      dp[i + 1][0] += dp[i][0] * 2 + dp[i][1];
      dp[i + 1][1] += dp[i][1];
    }
  }
  
  cout << dp[n][0] << '\n';
}
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define forn(i,x1,n)     for(int i=x1; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x1)      __builtin_popcountll(x1)
#define zrobits(x1)      __builtin_ctzll(x1)
#define mod             1000000007
// #define mod             998244353
#define inf             1e18
#define ps(x1,y)         fixed<<setprecision(y)<<x1
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x1)            int x1; cin>>x1; while(x1--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

	zeus();

	int n, q; cin >> n >> q;

	int a[n + 1];

	forn(i, 0, n) {
		cin >> a[i];
	}
	a[n] = 0;

	sort(a, a + n + 1);
	int diff[n];

	forn(i, 0, n) {
		diff[i] = a[i + 1] - a[i] - 1;
	}
	int prefixsum[n + 1];
	prefixsum[0] = 0;

	forn(i, 0, n) {
		prefixsum[i + 1] = prefixsum[i] + diff[i];
	}

	forn(i, 0, q) {
		int k; cin >> k;
		auto ind = lower_bound(prefixsum, prefixsum + n + 1, k) - prefixsum;
		cout << a[ind - 1] + k - prefixsum[ind - 1] << endl;
	}



}