package main import ( "bufio" "fmt" "os" "strconv" "sort" "strings" _ "math" ) func main() { scanner := bufio.NewScanner(os.Stdin) hold := []int{} edit_raw := make(map[int]string) for scanner.Scan() { for _, num_s := range strings.Split(scanner.Text(), " ") { runes := []rune(num_s) for i, r := range runes{ if r == []rune("4")[0] { runes[i] = []rune("7")[0] }else if r == []rune("7")[0] { runes[i] = []rune("4")[0] } } num, _ := strconv.Atoi(string(runes)) edit_raw[num] = num_s hold = append(hold, num) } break } nums := hold sort.Ints(nums) _, tail := nums[0], nums[1] fmt.Println(edit_raw[tail]) }