#include <iostream>
using namespace std;

long long cnt[200001];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    n <<= 1;
    for(int i = 2; i <= n; i++) {
        cnt[i] = min(i - 1, n - i + 1);
    }
    k = abs(k);
    long long result = 0;
    for(int i = k; i <= n; i++) {
        result += cnt[i] * cnt[i - k];
    }
    cout << result;
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
 
#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
 
const int MAX = 60 + 6;
ll memo[MAX][2];
string arr[MAX];
int n;

ll roll(int i, bool result) {
    if (i == 0) return 1;
    ll &ans = memo[i][result];
    if (~ans) return ans;

    if (arr[i - 1][0] == 'O') {
        if (!result) ans = roll(i - 1, false);
        else {
            ll a = roll(i - 1, false);
            ll b = 2 * roll(i - 1, true);
            ans = a + b;
        }
    }
    else {
        if (!result) {
            ll a = 2 * roll(i - 1, false);
            ll b = roll(i - 1, true);
            ans = a + b;
        }
        else ans = roll(i - 1, true);
    }

    return ans;
}

void solve() {
    cin >> n;
    fori (i, 0, n) cin >> arr[i];
    memset(memo, -1, sizeof memo);
    cout << roll(n, true) << endl;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}
