def check(n, f)
  sum = 0
  for i in 0..9
    if f[i] == 1
      sum += n ** i
    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) * T;
if ans == -1 || 1e+9 < ans
  puts "TLE"
else
  puts ans
end