#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return a * (b / gcd(a, b));
}
bool is(int h, int m) {
  if (m % 10 == h / 10 && h % 10 == m / 10) return true;
  return false;
}
int main() {
  int h, m;
  scanf("%d:%d", &h, &m);
  int add = 0;
  if (is(h, m)) {
    cout << 0;
    return 0;
  }
  while (true) {
    m++;
    add++;
    if (m == 60) {
      m = 0;
      h++;
    }
    if (h == 24) h = 0;
    if (is(h, m)) break;
  }
  cout << add;
  return 0;
}
