import Foundation
 
let inputLine: String = readLine()!
 
let a: Int64 = Int64(inputLine)!

 
var i = 1;
 
var ans = 0;
 
while i <= a {
  
 if i % 3 == 0 || i % 5 == 0 {
    i += 1
  	continue
  } 
	ans += i
    i += 1
}
 
print(ans)
