#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll TLE = 1000000000;

int main(){
  ll n,t;
  cin >> n >> t;
  string s;
  cin >> s;

  map<int,int> deg;
  for(int i=2;i<(int)s.size();i+=4){
    deg[s[i]-'0']++;
  }

  ll ans = 0;
  for(auto p : deg){
    ll tmp = 1;
    for(int i=0;i<p.first;i++){
      tmp *= n;
      if(tmp>TLE){
	ans = TLE+1;
	break;
      }
    }
    if(p.second*tmp>TLE){
      ans = TLE+1;
      break;
    }
    ans += p.second*tmp;
    if(ans>TLE)break;
  }

  if(ans>TLE || ans*t>TLE)cout << "TLE" << endl;
  else cout << ans*t << endl;
}