def check(n, f)
  sum = 0
  for i in 0..9
    if f[i] == 1
      add = n ** i
      if add == -1
        return -1;
      elsif 1e+9 < sum + add
        return -1;
      end
      sum += add;
    end
  end
  return sum;
end

n, T = gets.split.map(&:to_i)
s = gets
f = Array.new(10, 0)
for i in 0..s.size()-1
  if s[i] == "^"
    f[s[i+1].to_i] = 1
  end
end
ans = check(n, f);
if ans == -1
  puts "TLE"
else
  ans *= T
  if 1e+9 < ans
    puts "TLE"
  else
    puts ans
  end
end