class PhoneNumber(inpNumber: String) {
    init {
        if (inpNumber.length < 10) throw IllegalArgumentException()
        if ((inpNumber.length == 11) && !(inpNumber[0] == '1')) throw IllegalArgumentException()
    }
    private val digits: String = inpNumber.filter { it.isDigit() }
    val areaCode: String by lazy {
        number.substring(0..2)
    }
    val number: String by lazy {
        if (digits.length == 10) {
            digits.filter { it.isDigit() }.drop(0)
        }
        else digits.filter { it.isDigit() }.drop(0).drop(1)
    }

    override fun toString(): String {
        return "(" + number.subSequence(0..2) + ") " + number.subSequence(3..5)+ "-" + number.subSequence(6..9)
    }
}