#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long k = (s[0] - 48) + ((s[1] - 48) * 10);
  long long r = ((s[3] - 48) * 10) + (s[4] - 48);
  long long m = 0, h = 0;
  for (long long j = r; j <= 59; j++) {
    if (j == k) {
      h = 1;
      break;
    }
    m++;
  }
  if (h == 1) {
    cout << m;
  } else {
    long long p = 0, d = 1;
    long long f = (s[1] - 48) + ((s[0] - 48) * 10);
    while (p == 0) {
      long long g = f + d;
      d++;
      if (g == 24) {
        k = 0;
      } else {
        k = ((g % 10) * 10) + (g / 10);
      }
      for (long long i = 0; i <= 59; i++) {
        if (k == i) {
          p = 1;
          break;
        }
        m++;
      }
    }
    cout << m;
  }
  return 0;
}
