#!/usr/bin/env python3
import sys


def solve(X: int):
    happiness = 0
    gohyaku_maisuu, modulo = divmod(X, 500)
    happiness += gohyaku_maisuu * 1000
    happiness += (modulo // 5) * 5
    return happiness


def main():
    X = int(sys.stdin.readline().strip())  # type: int
    print(solve(X))


if __name__ == '__main__':
    main()

2b6fb37000c077208e26795ca8ed3c5a84160839
<mask token>


def main():
    X = int(sys.stdin.readline().strip())
    print(solve(X))


<mask token>

<mask token>


def solve(X: int):
    happiness = 0
    gohyaku_maisuu, modulo = divmod(X, 500)
    happiness += gohyaku_maisuu * 1000
    happiness += modulo // 5 * 5
    return happiness


def main():
    X = int(sys.stdin.readline().strip())
    print(solve(X))


<mask token>

<mask token>


def solve(X: int):
    happiness = 0
    gohyaku_maisuu, modulo = divmod(X, 500)
    happiness += gohyaku_maisuu * 1000
    happiness += modulo // 5 * 5
    return happiness


def main():
    X = int(sys.stdin.readline().strip())
    print(solve(X))


if __name__ == '__main__':
    main()

import sys


def solve(X: int):
    happiness = 0
    gohyaku_maisuu, modulo = divmod(X, 500)
    happiness += gohyaku_maisuu * 1000
    happiness += modulo // 5 * 5
    return happiness


def main():
    X = int(sys.stdin.readline().strip())
    print(solve(X))


if __name__ == '__main__':
    main()

#!/usr/bin/env python3
import sys


def solve(X: int):
    happiness = 0
    gohyaku_maisuu, modulo = divmod(X, 500)
    happiness += gohyaku_maisuu * 1000
    happiness += (modulo // 5) * 5
    return happiness


def main():
    X = int(sys.stdin.readline().strip())  # type: int
    print(solve(X))


if __name__ == '__main__':
    main()
