import Foundation
 
let inputLine: String = readLine()!
 
let a: Int64 = Int64(inputLine)!
 
var i = 1;
 
var ans = 0;
 
while i <= a {
 if a % 3 == 0 || a % 5 == 0 {
  	continue
  } 
	ans += i
}
 
 
print(ans)