#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
#include <cmath>
using namespace std;

typedef string::const_iterator iter;

double expr(iter &it);
double term(iter &it);
int number(iter &it);

int N;
double expr(iter &it) {
    double r = term(it);
    while(*it == '+') {
        it++; // skip +
        r += term(it);
    }
    return r;
}

double term(iter &it) {
    it++; // skip n
    it++; // skip ^
    int k = number(it);
    return pow<double>(N, k);
}

int number(iter &it) {
    int r = *it - '0';
    it++;
    return r;
}

int main(void) {
    int T;
    cin >> N >> T;
    string s; cin >> s;
    iter it = s.begin();
    double r = expr(it);
    if(T*r > 1e9) {
        cout << "TLE" << endl;
    } else {
        cout << (int)(T * r) << endl;
    }
}