#include<bits/stdc++.h>
#define mp make_pair
#define endl "\n"
#define v vector
#define b begin()
#define e end()
using namespace std;
typedef long long ll;
typedef long l;
typedef long long unsigned ull;

int main(){

    /*int t;
    while(t--){

    }*/
    ll n;
    cin>>n;
    ll m = n/500;
    ll q = m*1000;
    n -= (m*500);
    ll p = (n/5)*5;
    cout<<q+p;

    return 0;

}
#include<iostream>
using namespace std ;

int main()
{
  string S ;
  cin>>S ;
  
  int SIZE=S.size() ;
  if(SIZE==2) cout<<S<<endl ;
  else for(int i=SIZE-1;i>=0;i--) cout<<S.at(i) ;
  
  return 0 ;
}