#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int main() {
  scanf("%d:%d", &n, &m);
  while (1) {
    if (n % 10 == m / 10 && n / 10 == m % 10) break;
    ans++;
    m++;
    if (m == 60) {
      m = 0;
      n++;
    }
    if (n == 24) n = 0;
  }
  printf("%d\n", ans);
  return 0;
}
