#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void computeLPSArray(string pattern, int m, int lps[]){
    int len=0;
    lps[0]=0;   //lps[0] is always 0
    int i=1;
    while(i<m){
        if(pattern[i]==pattern[len]){
            len++;
            lps[i]=len;
            i++;
        }else{
            if(len!=0)
                len=lps[len-1];
            else{
                lps[i]=0;
                i++;
            }
        }
    }
}
void kmpSearch(string str,string pattern){
    int m=pattern.length();
    int n=str.length();
    int lps[m];  //longest prefix suffix array
    computeLPSArray(pattern,m,lps);
    int i=0; //text
    int j=0; //pattern
    bool found=0;
    while(i<n){
        if(pattern[j]==str[i]){
            i++;
            j++;
        }
        if(j==m){
            j=lps[j-1];
            found=1;
            break;
        }else if(i<n && pattern[j]!=str[i]){
            if(j!=0) j=lps[j-1];
            else i=i+1;
        }
    }
    if(!found)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str,pattern;
    while(cin>>str){
        pattern="AC";
        kmpSearch(str,pattern);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll x;cin >> x;

    int t=x/500;
    int f=(x-t*500)/5;

    cout << 1000*t+5*f << endl;

    return 0;
}



