/** libraries */
#include
#include
#include
#include
#include
#include
#include
#include
/** libraries */
using namespace std;
/** defines */
#define ll long long
#define ld long double
#define yes cout << "YES" << "\n"</strong>
#define no cout << "NO" << "\n"</strong>
/** defines */
vector a;
bool ok(ll num){
return num % 6 == 0 && num % 10 == 4;
}
void solve(){
ll sum = 0;
for(auto i: a)
if(ok(i))
sum += i;
cout << sum;</strong>
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
while(true){
ll x;
cin >> x;
if(x == 0)
break;
a.push_back(x);
}
solve();
}