Problem:
Score : 200 points

Problem Statement

Takahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)

Takahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?

(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)

Constraints

0 \leq X \leq 10^9

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

Print the maximum number of happiness points that can be earned.

Sample Input 1

1024

Sample Output 1

2020

By exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.

Sample Input 2

0

Sample Output 2

0

He is penniless - or yenless.

Sample Input 3

1000000000

Sample Output 3

2000000000

He is a billionaire - in yen.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1e+7
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

void A(){
  string s;
  cin >> s;
  if(s[2] == s[3] and s[4] == s[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

void B(){
  int Yen;
  cin >> Yen;
  ll Happiness = 0;
  while(Yen >= 500){
    Happiness += 1000;
    Yen -= 500;
  }
  while(Yen >= 5){
    Happiness += 5;
    Yen -= 5;
  }

  cout << Happiness << endl;
}

void C(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  rep(i,N){
    cin >> A[i];
  }
  ll min = A[N-1] - A[0];
  for(int i = 1; i < N; i++){
    ll temp = K - (A[i] - A[i-1]);
    temp < min ? min = temp:1;
  }

  cout << min << endl;
}
int main(){
  B();
}